Hi,<br><br>Thanks for the info Eric. <br>I'll follow up on activating/deactivating the select feature control.<br>Maybe it would increase the performance of the application since the controls are created only once.<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;">
Indika<br>
<br>
So you just let the user choose what layer feature selection works for, right?<br>
<br>
I don't know about Sebastien's case but in lots of situations this<br>
isn't acceptable - it's a pain for the user to select the type of<br>
objects he's going to query.<br>
<br>
On an unrelated note, I notice that you create a new control each time<br>
the user switches layer type, instead you could probably have two<br>
select feature controls and activate/deactivate them based on the<br>
selected radio button.<br>
<br>
Eric<br>
<br>
2008/11/26, Indika Tantrigoda <<a href="mailto:indika85@gmail.com">indika85@gmail.com</a>>:<br>
<div><div></div><div class="Wj3C7c">> Hi,<br>
><br>
> After looking at<br>
> <a href="http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/styles_unique_with_group_wfs.htmlI" target="_blank">http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/styles_unique_with_group_wfs.htmlI</a><br>
> managed to find a<br>
> work around . I have two wfs point layers, and can activate the<br>
> 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<br>
> the needed layer is selected via the radio buttons the selected layer is<br>
> superimposed.<br>
><br>
> Heres my code<br>
><br>
> //inside init()<br>
><br>
> var myHTML = "<input type=radio name=myRadio<br>
> onclick=test(2)><label>Cities</label> <img src='./img/marker-blue.png'><br>
> <br>" myHTML += "<input type=radio name=myRadio<br>
> 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<br>
> OpenLayers.Control.SelectFeature(map.layers[id],<br>
><br>
> {<br>
><br>
> onSelect : onFeatureSelect,<br>
><br>
> onUnselect: onFeatureUnselect<br>
><br>
> });<br>
><br>
> map.addControl(selectControl);<br>
> selectControl.activate();<br>
><br>
> //I didnt think this it necessary to unregister because the<br>
> control is destroyed above<br>
> //map.layers[id].events.unregister('featureselected',<br>
> map.layers[id], regFeatureSelected);<br>
> //map.layers[id].events.unregister('featureunselected',<br>
> 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>
><br>
> obj.geometry.getBounds().getCenterLonLat(),<br>
> null,<br>
> "<div style='font-size:.8em'>" +<br>
> 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>
> 2008/11/26 Eric Lemoine <<a href="mailto:eric.c2c@gmail.com">eric.c2c@gmail.com</a>><br>
><br>
>> 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>
>> Yes.<br>
>><br>
>> --<br>
>> Eric<br>
>> _______________________________________________<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>
>><br>
><br>
</div></div></blockquote></div><br>