<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Eric Lemoine schreef:
<blockquote
 cite="mid:ca7da9120911190146g46973d68gc9f4459275d2d6d1@mail.gmail.com"
 type="cite">
  <blockquote type="cite">
    <pre wrap="">Like the example at
<a class="moz-txt-link-freetext" href="http://openlayers.org/dev/examples/getfeature-wfs.html">http://openlayers.org/dev/examples/getfeature-wfs.html</a>, 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;
    }
});


Hi Eric,

What I would like is to fill the vector layer at initialization with the
known features from the associated wfs layer. The beforefeatureadded event
would still require the user to select features and then only adds the known
features. But how to fill the vector layer with these features, without any
action from the user?
    </pre>
  </blockquote>
  <pre wrap=""><!---->
I don't get it. beforefeatureadded is triggered for every feature
added to the layer, it has nothing to do with the user selecting
features, hasn't it?
  </pre>
</blockquote>
But where (or when) do the features come from? The
OpenLayers.Protocol.WFS.fromWSMLayer function doesn't automatically
fetch features from the wfs layer, but only in response to a click
event. I would like it to automatically fetch (some) features at
startup but don't know how.<br>
<br>
John.
<pre class="moz-signature" cols="72">------
</pre>
</body>
</html>