Indika So you just let the user choose what layer feature selection works for, right?
I don't know about Sebastien's case but in lots of situations this isn't acceptable - it's a pain for the user to select the type of objects he's going to query. On an unrelated note, I notice that you create a new control each time the user switches layer type, instead you could probably have two select feature controls and activate/deactivate them based on the selected radio button. Eric 2008/11/26, Indika Tantrigoda <[EMAIL PROTECTED]>: > Hi, > > After looking at > http://gis.ibbeck.de/ginfo/apps/OLExamples/OL26/examples/styles_unique_with_group_wfs.htmlI > managed to find a > work around . I have two wfs point layers, and can activate the > selectFeature for the currently selected layer via a radio button. > > 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. > > Heres my code > > //inside init() > > 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'>" > > document.getElementById("controls").innerHTML = myHTML; > // > > //outside init() > > var myLayer; //global variable > var myObj; //global variable > > function test(id) { > > myLayer =id; > > if(selectControl) > { > //alert("Hiiiiiiiiiiiii"); > selectControl.destroy(); > } > > selectControl = new > OpenLayers.Control.SelectFeature(map.layers[id], > > { > > onSelect : onFeatureSelect, > > onUnselect: onFeatureUnselect > > }); > > map.addControl(selectControl); > selectControl.activate(); > > //I didnt think this it necessary to unregister because the > control is destroyed above > //map.layers[id].events.unregister('featureselected', > map.layers[id], regFeatureSelected); > //map.layers[id].events.unregister('featureunselected', > map.layers[id], regFeatureUnselected); > } > > function onFeatureSelect() > { > var currentLayer = map.layers[myLayer]; > var obj = currentLayer.selectedFeatures[0]; > myObj = obj > //alert(obj.attributes['name']); > > popup = new OpenLayers.Popup.FramedCloud("chicken", > > obj.geometry.getBounds().getCenterLonLat(), > null, > "<div style='font-size:.8em'>" + > obj.attributes['name'] +"<br />" + "</div>", > null, true, onPopupClose); > obj.popup = popup; > map.addPopup(popup); > } > > function onPopupClose(evt) { > selectControl.unselect(myObj); > } > > function onFeatureUnselect() > { > //alert("from regFeatureUnselected"); > > map.removePopup(myObj.popup); > myObj.popup.destroy(); > myObj.popup = null; > } > > > Hope this was helpful. > > Indika > > > 2008/11/26 Eric Lemoine <[EMAIL PROTECTED]> > >> On Wed, Nov 26, 2008 at 10:20 AM, Sébastien Geindre >> <[EMAIL PROTECTED]> wrote: >> > Eric Lemoine a écrit : >> >> >> >> Seb, I don't understand your question. If you're trying to get the >> >> select feature control to work with multiple layers then you must know >> >> that that isn't currently supported by OpenLayers. Sorry for not >> >> understanding your question. Eric >> > >> > you guessed it ! >> > >> > is there any workaround ? >> > >> > all features must be on the same layer ? >> >> Yes. >> >> -- >> Eric >> _______________________________________________ >> Users mailing list >> Users@openlayers.org >> http://openlayers.org/mailman/listinfo/users >> > _______________________________________________ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users