[OpenLayers-Users] how to initialize 'WFS.fromWMSLayer' with features

Eric Lemoine eric.lemoine at camptocamp.com
Thu Nov 19 01:33:01 EST 2009


On Wednesday, November 18, 2009, John Pulles <john.pulles at geodan.nl> wrote:
> Hi list,
>
> Like the example at
> http://openlayers.org/dev/examples/getfeature-wfs.html, I am using the
> OpenLayers.Protocol.WFS.fromWSMLayer convenience function to select
> features from a wms layer and collect the values of a certain attribute.
> When opening the same map a next time, I would like to show which
> features were selected. Now I'm looking for a way to add features to the
> wfs layer based on some attribute values, what would be the easiest way?

you can register a "beforefeatureadded" listener on the vector layer,
something like that:

layer.events.on({
    beforefeatureadded: function(e) {
        // only add features whose foo attribute
        // is set to "bar"
        return e.feature.attributes.foo == "bar" ?
             true : false;
    }
});

cheers,


-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com



More information about the Users mailing list