Performance problem while switching between layers using "setVisibility" (show/hide layers one by one)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Performance problem while switching between layers using "setVisibility" (show/hide layers one by one)

Rajat Arora
Hi, 

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

_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev
Reply | Threaded
Open this post in threaded view
|

Re: Performance problem while switching between layers using "setVisibility" (show/hide layers one by one)

Phil Scadden
This belongs in the openlayers-user group.

Vector layers with large nos of vertices do not well as you have found
because the drawing has to be done is JS. You will get far better
performance if you use WMS for display and WFS for query. (eg
http://openlayers.org/dev/examples/getfeature-wfs.html). For more
advanced queries, create the protocol as per example from WMS, and use
it for queries. This was discussed recently (and often) in the user
mailing list. You may even have a case for using WMS-T.

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.

_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev