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>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">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">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>