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

John Pulles john.pulles at geodan.nl
Thu Nov 19 09:52:46 EST 2009


bartvde at osgis.nl schreef:
> Call the read function on the returned protocol yourself.
>   
Thanks Bart and Eric for your help.

The (or a) solution is indeed to call the read function with a filter 
and callback funtion as options parameters. The callback function adds 
the features in the wfs response to the vector layer.

Cheers,
John
> Best regards,
> Bart
>
>   
>> Eric Lemoine schreef:
>>     
>>>> 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;
>>>>     }
>>>> });
>>>>
>>>>
>>>> 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?
>>>>
>>>>         
>>> 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?
>>>
>>>       
>> 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.
>>
>> John.
>>
>> ------
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>>     
>
>
>
>
>
>   


-- 

-------------------------------------
Geodan IT b.v.
Buitenhaven 27-A
5211 TP 's-Hertogenbosch (NL)
-------------------------------------
Tel: +31 (0)73 - 692 5151
Fax: +31 (0)20 - 5711 333
-------------------------------------
Postadres / mailing address
President Kennedylaan 1
1079 MB Amsterdam (NL)
-------------------------------------
E-mail: john.pulles at geodan.nl
Website: http://www.geodan.nl
Disclaimer: http://www.geodan.nl/disclaimer
-------------------------------------

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20091119/ebe7d7b4/attachment.html


More information about the Users mailing list