[OpenLayers-Users] Preloading WFS feature data [SEC=UNCLASSIFIED]

Andreas Hocevar ahocevar at opengeo.org
Thu Feb 25 08:31:27 EST 2010


Hi,

you should loop through your feature in a listener function to the 
"loadend" event of the layer.

Also, if you are using Layer.Vector with Protocol.WFS, you can provide a 
filter property on the layer, configured with an OpenLayers.Filter, to 
filter your features on the server side, instead of loading them all and 
filtering on the client.

Another option, if you want to stick with loading all features to the 
client, is to provide a StyleMap, configured with a Style that has a 
context option, where you can set the symbolizer's "display" property to 
"none" in a context function, for features that you don't want to show up.

Look at the examples [1] and [2] to get a clue of how this works.

Regards,
Andreas.

[1] http://openlayers.org/dev/examples/wfs-protocol.html
[2] http://openlayers.org/dev/examples/styles-context.html


John Phan wrote:
> Hi,
> 
> I have a vector layer with some feature data. The layer is not
> visible at first (vectorLayer.setVisibility(false)), but made visible
> when user starts selecting an option. But I only want certain vector
> points drawn based on their feature attributes (i.e.
> vectorLayer.features.attributes.<data>).
> 
> When a user option is selected, I loop through all features (i.e.
> vectorLayer.features.length). Set renderIntent to no display (
> OpenLayers.Style({display: "none"}) ) for the vector point if its
> feature attribute ( vectorLayer.features.attributes.<data> ) does not
> match user input.
> 
> This only works when all the feature data are loaded onto the
> browser. That is all features are drawn because I can't enter the
> loop the first time (length=0)
> 
> Does anyone know how to preload those features before the layer is
> made visible the first time?
> 
> Thanks, John
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> 
> _______________________________________________ Users mailing list 
> Users at openlayers.org http://openlayers.org/mailman/listinfo/users


-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.



More information about the Users mailing list