[OpenLayers-Users] how select the right feature between 2
superimposed ?
Indika Tantrigoda
indika85 at gmail.com
Thu Nov 27 00:24:51 EST 2008
Hi,
Thanks for the info Eric.
I'll follow up on activating/deactivating the select feature control.
Maybe it would increase the performance of the application since the
controls are created only once.
Indika
2008/11/26 Eric Lemoine <eric.c2c at gmail.com>
> 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 <indika85 at gmail.com>:
> > 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 <eric.c2c at gmail.com>
> >
> >> On Wed, Nov 26, 2008 at 10:20 AM, Sébastien Geindre
> >> <sebastien.geindre at meteo.fr> 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 at openlayers.org
> >> http://openlayers.org/mailman/listinfo/users
> >>
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20081127/320f529c/attachment.html
More information about the Users
mailing list