[OpenLayers-Users] Cache maps with OSM

hz hanks hankshz at gmail.com
Fri Sep 21 17:53:24 PDT 2012


Hey, All:

I have created a simple web based map application using
OpenLayers.Layer.OSM. Now I'm asked to cache part of the map in
advance. ( Say, cache it when it's accessible to the Internet and then
we may move the laptop to a place without the Internet. )

My idea is to use setCenter( center, zoom ) function to change the
zoom argument and let the OpenLayer to cache the data. I went through
the example of offline-storage.js provided by OpenLayer and now how to
add cache control. But how can I make sure that all data is cached
before I change the zoom argument again? I tried to register event
"loadend" ( change the zoom argument after "loadend" is triggered )
but it didn't work. Did I choose a wrong event? Or is this idea not
feasible ( caching every tile that has been displayed is not
guaranteed? ). Is there any other way to do that (e.g. create a
offline map of a desired area) and how?

Thanks a lot!

Best,
Hanks


More information about the Users mailing list