[OpenLayers-Users] How to trigger featuresselected event on several layers at once?

Ian Frank ianfrankbauer at googlemail.com
Tue Mar 15 04:09:48 EDT 2011


Hello all,
I have a group Layer:
    group_layer = new OpenLayers.Layer.WMS(
        "Group Layer",
        geoserverUrl,
        {
            layers: ['gsns:layer1', 'gsns:layer2'],
            styles: ['', '']
        },
        {
            isBaseLayer: false,
        }
    );

Now I want to register featuresselected event and trigger it on both
'gsns:layer1' and 'gsns:layer2' at once:

    groupControl = new OpenLayers.Control.GetFeature({
        protocol: OpenLayers.Protocol.WFS.fromWMSLayer(group_layer),
        box: false,
        toggleKey: "ctrlKey",
        multiple: true,
        single: false
    });

    groupControl.events.register('featuresselected', this, function(e) {
        if features from both gsns:layer1 and gsns:layer2 are selected
consider only feature
        from gsns:layer2 otherwise consider feature from selected layer.
    });

But unfortunately in this way GetFeature is performed only for the first
layer 'gsns:layer1' and 'gsns:layer2' is ignored.
Any hints?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110315/426c43fe/attachment.html


More information about the Users mailing list