[OpenLayers-Users] Select feature on multiple layers works just for one layer

Diego Pasqualin dpasqualin at gmail.com
Thu Dec 1 19:45:38 EST 2011


Hello everyone,
I know that this is a common question, but I've searched on archives and
also tried the examples but I've been failing miserably.

All I need is to attach two layers to a SelectFeature control. I expect to
execute something when the user clicks on a feature of any of the layers.

---------------------------8<----------------------------------------------------------------------

    /* Control to allow user to click on indicators */
    var layers = [entities.layer_office, suburbs.suburbs_layer];
    select_control = new OpenLayers.Control.SelectFeature(layers, {
        clickout: true,
        onSelect: function(e) {
            console.log(e);
        },
        onUnselect: function(e) {
            console.log(e);
        }
    });

    map.addControl(select_control);
    select_control.activate();
---------------------------8<----------------------------------------------------------------------


Entities.layer_office and suburbs.suburbs_layer are Vector Layers with
Feature.Vector attributes.
If I add just entities.layer_office, it works.
If I add just suburbs.suburbs_layer, it works.
If I add both (regardless of the order), the suburbs.suburbs_layer receive
the events, but entities.layer_office doesn't.

Any suggestion about what I might be doing wrong?

Thank you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20111202/463d30e5/attachment.html


More information about the Users mailing list