I've taken the select control out entirely, and the highlight works independently of the select control. Do I need to specify a click handler? <br><br><div class="gmail_quote">On Tue, Jun 16, 2009 at 4:39 PM, Eric Lemoine <span dir="ltr"><<a href="mailto:eric.lemoine@camptocamp.com">eric.lemoine@camptocamp.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On Tuesday, June 16, 2009, Nicholas Efremov-Kendall<br>
<div class="im"><<a href="mailto:n.e.kendall@gmail.com">n.e.kendall@gmail.com</a>> wrote:<br>
> Hi all,<br>
><br>
> another novice error probably. I'm trying to replicate the function of the click to select, highlight selected example. I essentially copy/pasted the example into my code, but I'm perplexed as to why I don't have the select on click feature activated? The highlighting works fine, but nothing happens when I click. My current set up is very close to the example, except I use a local gml rather than the vectors from the wkt geometry.<br>
> here's my code, and I'm using the web-url for the code.<br>
<br>
</div>Looking at your code I have no idea what's wrong. Have you try<br>
removing the hover (highlightOnly) control to see if the click control<br>
then works?<br>
<div><div></div><div class="h5"><br>
><br>
> var map, controls;<br>
> function init() {<br>
> map = new OpenLayers.Map ("map",<br>
> {<br>
> controls:[<br>
> new OpenLayers.Control.Navigation(),<br>
> new OpenLayers.Control.PanZoomBar(),<br>
> new OpenLayers.Control.LayerSwitcher(),<br>
> new OpenLayers.Control.Attribution()],<br>
> sphericalMercator: true,<br>
> maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),<br>
> maxResolution: 156543.0399,<br>
> numZoomLevels: 19,<br>
> units: 'm',<br>
> projection: new OpenLayers.Projection("EPSG:900913"),<br>
> displayProjection: new OpenLayers.Projection("EPSG:4326"),<br>
> }<br>
> );<br>
> var myBaseLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS",<br>
> "<a href="http://labs.metacarta.com/wms/vmap0" target="_blank">http://labs.metacarta.com/wms/vmap0</a>", {layers: 'basic', projection: "myproj"} );<br>
> map.addLayer(myBaseLayer);<br>
><br>
> var topo = new OpenLayers.Layer.GML("Topography", "data/test4.gml", {<br>
> projection: new OpenLayers.Projection("EPSG:4326")});<br>
> map.addLayer(topo);<br>
> // Selection and hoverstate controls<br>
> var report = function(e) {<br>
> OpenLayers.Console.log(e.type, <a href="http://e.feature.id" target="_blank">e.feature.id</a>);<br>
> };<br>
><br>
> var highlightCtrl = new OpenLayers.Control.SelectFeature(topo, {<br>
> hover: true,<br>
> highlightOnly: true,<br>
> renderIntent: "temporary",<br>
> eventListeners: {<br>
> beforefeaturehighlighted: report,<br>
> featurehighlighted: report,<br>
> featureunhighlighted: report<br>
> }<br>
> });<br>
><br>
> var selectCtrl = new OpenLayers.Control.SelectFeature(topo,<br>
> {clickout: true}<br>
> );<br>
><br>
> map.addControl(highlightCtrl);<br>
> map.addControl(selectCtrl);<br>
><br>
> highlightCtrl.activate();<br>
> selectCtrl.activate();<br>
><br>
> if( ! map.getCenter() ){<br>
> topo.events.register('loadend', topo, function(){map.zoomToExtent(topo.getDataExtent())});<br>
> map.setCenter(null, null);<br>
> };<br>
> }<br>
><br>
><br>
<br>
</div></div>--<br>
Eric Lemoine<br>
<br>
Camptocamp France SAS<br>
Savoie Technolac, BP 352<br>
73377 Le Bourget du Lac, Cedex<br>
<br>
Tel : 00 33 4 79 44 44 96<br>
Mail : <a href="mailto:eric.lemoine@camptocamp.com">eric.lemoine@camptocamp.com</a><br>
<a href="http://www.camptocamp.com" target="_blank">http://www.camptocamp.com</a><br>
</blockquote></div><br>