Hi,<br><br>After looking at <a href="http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/styles_unique_with_group_wfs.html">http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/styles_unique_with_group_wfs.html</a> I managed to find a<br>
work around . I have two wfs point layers, and can activate the selectFeature for the currently selected layer via a radio button.<br><br>Some of my features were superimposed on top of other layers. However when the needed layer is selected via the radio buttons the selected layer is superimposed.<br>
<br>Heres my code<br><br>//inside init()<br><br>var myHTML = "<input type=radio name=myRadio onclick=test(2)><label>Cities</label> <img src='./img/marker-blue.png'> <br>" myHTML += "<input type=radio name=myRadio onclick=test(3)><label>Stations</label> <img src='./img/marker-gold.png'>"<br>
<br> document.getElementById("controls").innerHTML = myHTML;<br>//<br><br>//outside init()<br><br> var myLayer; //global variable<br> var myObj; //global variable<br> <br> function test(id) {<br>
<br> myLayer =id;<br> <br> if(selectControl)<br> {<br> //alert("Hiiiiiiiiiiiii");<br> selectControl.destroy();<br> }<br>
<br> selectControl = new OpenLayers.Control.SelectFeature(map.layers[id], <br> {<br> onSelect : onFeatureSelect,<br>
onUnselect: onFeatureUnselect<br> });<br>
<br> map.addControl(selectControl);<br> selectControl.activate();<br> <br> //I didnt think this it necessary to unregister because the control is destroyed above<br>
//map.layers[id].events.unregister('featureselected', map.layers[id], regFeatureSelected);<br> //map.layers[id].events.unregister('featureunselected', map.layers[id], regFeatureUnselected);<br>
}<br> <br> function onFeatureSelect()<br> {<br> var currentLayer = map.layers[myLayer];<br> var obj = currentLayer.selectedFeatures[0];<br> myObj = obj<br>
//alert(obj.attributes['name']);<br> <br> popup = new OpenLayers.Popup.FramedCloud("chicken", <br> obj.geometry.getBounds().getCenterLonLat(),<br>
null,<br> "<div style='font-size:.8em'>" + obj.attributes['name'] +"<br />" + "</div>",<br>
null, true, onPopupClose);<br> obj.popup = popup;<br> map.addPopup(popup);<br> }<br> <br> function onPopupClose(evt) {<br> selectControl.unselect(myObj);<br>
}<br> <br> function onFeatureUnselect()<br> {<br> //alert("from regFeatureUnselected");<br> <br> map.removePopup(myObj.popup);<br>
myObj.popup.destroy();<br> myObj.popup = null;<br> }<br><br><br>Hope this was helpful.<br><br>Indika<br><br><br><div class="gmail_quote">2008/11/26 Eric Lemoine <span dir="ltr"><<a href="mailto:eric.c2c@gmail.com">eric.c2c@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">On Wed, Nov 26, 2008 at 10:20 AM, Sébastien Geindre<br>
<<a href="mailto:sebastien.geindre@meteo.fr">sebastien.geindre@meteo.fr</a>> wrote:<br>
> Eric Lemoine a écrit :<br>
>><br>
>> Seb, I don't understand your question. If you're trying to get the<br>
>> select feature control to work with multiple layers then you must know<br>
>> that that isn't currently supported by OpenLayers. Sorry for not<br>
>> understanding your question. Eric<br>
><br>
> you guessed it !<br>
><br>
> is there any workaround ?<br>
><br>
> all features must be on the same layer ?<br>
<br>
</div>Yes.<br>
<br>
--<br>
<font color="#888888">Eric<br>
</font><div><div></div><div class="Wj3C7c">_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@openlayers.org">Users@openlayers.org</a><br>
<a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
</div></div></blockquote></div><br>