[OpenLayers-Dev] Performance problem while switching between layers using "setVisibility" (show/hide layers one by one)

Rajat Arora rajata07 at gmail.com
Mon Oct 1 08:42:06 PDT 2012


I have a scenario in which there are 24 Vector layers. I am adding plenty of features into these layers. 
For example: 16000 feature to every layer (which means 16000 * 24 total features in 24 different layers)
And once the features are added, I want to switch b/w these layers with certain interval in order to see kind of animation. 
I am using setInterval function of JavaScript and showing/hiding the layer visibility after certain interval using "setVisibility" function of open layers.
However, I believe that setVisibility function is re-drawing the features every time it is called. I have seen that there is another function called "layer.display"
which can be used to show and hide the layers. But this doesn't work in my case because I set the layer visibility of all layers to false before adding the features to map.  

For better explanation, pseudo code as follows: 

1. Request from client - Draw Feature on map
2. Request sent to server for fetching data ( geometry value and other attributes)
3. Response received.
4. Set layer's visibility to false - before creating features so that adding features are bit faster.
5. Create vector features on client side and add them to corresponding layers. 
6. Once the feature creation is finished, set Visibility of one layer(first one) to true. 
7. Finally, allow user to switch between layer with certain interval by providing a play button.
8. Pressing on play button start switching between layers. (using setVisibility)

The problem in above case is that, setting layer visibility to true and false is bit slow when there are more features. 
Is there any alternative function or approach i can use to implement this behaviour using open layers ?

Best Regards,
Rajat Arora
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20121001/4109f186/attachment.html>

More information about the Dev mailing list