I have a project using OpenLayers which displays radar data on a map. The radar data itself is just a bunch of polygons each of which is filled with one of 6 possible colors. The goal is to animate the radar on the map. Each file contains radar data for a given time and the files are separated by about 5 minutes so my current approach is to loop through all the files and load them one by one into new separate layers. Once each layer is created it has its visibility set to false and it's added to the map. I then animate the layers using a timer which turns on the visibility of one layer and turns off the visibility of the preceding layer. Currently the layers are all vector layers and the data is loaded from KML files although the data files can be pretty much any format that will work best for this project.

The problem with this approach is that once I hit a fairly large time span (around 3 hours or so) of data (equating to approximately 36 layers) the memory consumption gets pretty high (around 250mb). The final product is supposed to be able to handle up to 18 hours of data in one loop which based on the above number would require over 1GB of memory just for the animation and would likely crash the browser or at least make it very sluggish.

I attempted the same thing using WMS layers for each layer but the redrawing was too slow (the animation changes layers every 100ms) and the memory consumption wasn't much better than the vector version.

I have scoured the net trying to find some example of how to do this but so far am coming up empty handed. Does anyone out there have any suggestions on how to do this? I'll take any ideas you have at this point as I've been stuck on this for weeks now with no answer in sight.

3 Answers 3


Try a sliding window of sorts. You can buffer 10 layers at a time. Start destroying layers and removing them from the DOM and memory once you reach 10 layers. So once you hit layer 10, layer 0-9 are destroyed and layers 20-30 are loaded with visibility to false. This will give you a buffer of about 10 layers but you can modify your tolerance as you see fit for performance. If you feel 20 layers works better, go with 20.

          {Destroy Layers} |10|11...19|20| {Start Loading Layers}
        Timespan           Current Possition
  • You sir are a genius! I haven't actually put this into practice yet but I don't see any reason for it to not work, and the adjustable buffer means we can further customize this for varying environments. I cannot thank you enough for this suggestion!
    – TheOx
    Commented Feb 25, 2012 at 0:18
  • Thanks, I hope it works in practice. Let us know how it works out.
    – CaptDragon
    Commented Feb 27, 2012 at 13:38
  • Just completed initial testing and it is working well! There's still some room for optimization in the code but this method keeps the memory footprint way down and is configurable based on the client machine's memory and bandwidth. Thanks again for the excellent suggestion!
    – TheOx
    Commented Mar 1, 2012 at 20:27
  • Awesome, good to hear that.
    – CaptDragon
    Commented Mar 1, 2012 at 20:47
  • @CaptDragon: (or TheOx) Would it be possible to post to a working example? I understand the solution to a point but seeing a simple example and the code would greatly help as I have pretty much the same issue. Thanks! Commented Jan 6, 2014 at 21:44

Have you considered simplifying the vector layers to reduce their file size. If the polygons contain more vertices than are needed for the purposes of your display then simplifying (smoothing) them will reduce the file size with the cost of reduced detail. I'm not sure what software you have at your disposal but several GIS desktop applications contain a geoprocessing function to simplify features.

  • It's a good idea but unfortunately the project requires displaying the data in its full resolution. However I will keep that in mind for some other data layers down the road where we might be able to use that trick.
    – TheOx
    Commented Feb 25, 2012 at 0:15

Other than simplifying the data (even a little may save a lot of space) have you tried MapServer or some other way of turning your data into tiles with transparency and creating a map layer to lay on top of the background layer. I've seen this approach with choropleth maps that have hundreds to hundreds of thousands of polygons (or markers), but haven't been able to try it myself yet (due to the server side requirement).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.