[OpenLayers-Users] how select the right feature between 2 superimposed ?

Indika Tantrigoda indika85 at gmail.com
Fri Dec 5 23:21:28 EST 2008


Hi Sébastien,
*
*Are you referring to features superimposed on the same layer ? If so what
you described would be a useful thing
to have when multiple features are superimposed. I dont think I have come
across anything of this nature. Has anyone else ?

However if the two superimposed features are on different layers, the
currently activated selectFeature control for that
particular layer would select only features from the mentioned layer. But if
multiple features are superimposed on the
selected layer you run in to the issue mentioned above.

Regards,
Indika


2008/12/4 Sébastien Geindre <sebastien.geindre at meteo.fr>

> Do you think there is a way to select the layer after the event is thrown ?
>
> Imagine, you click the mouse on a feature, in fact on 2 features -
> superimposed -, the UI shows you the both features, and you could select
> one....draw the attributes of the selected one....
>
> but for that, we need have event thrown on each layer...
> which is not possible...
>
> am i right ?
>
>
> Indika Tantrigoda a écrit :
>
>> 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 <mailto: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
>>    <mailto: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
>>    <mailto:eric.c2c at gmail.com>>
>>     >
>>     >> On Wed, Nov 26, 2008 at 10:20 AM, Sébastien Geindre
>>     >> <sebastien.geindre at meteo.fr <mailto: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 <mailto: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/20081206/44db061c/attachment.html


More information about the Users mailing list