[OpenLayers-Users] Cache maps with OSM

hz hanks hankshz at gmail.com
Mon Sep 24 16:57:21 PDT 2012


Hey, Stephen:

Thanks a lot for your detailed reply!

Yea, actually I just found out one called TileCache which is quite
similar to mapcache. And it's working now actually, but only for WMS.
Due to some business reasons, I need to use OpenStreetMap instead.
Dose the mapcache support OpenStreetMap or any possible solution to
hack that?

Thanks again!

Best,
Hanks

2012/9/24 Stephen Woodbridge <woodbri at swoodbridge.com>:
> On 9/24/2012 4:18 PM, hz hanks wrote:
>>
>> Hey, Stephen:
>>
>> Downloading the completed data is feasible but, as you mentioned, need
>> much larger disk to store the data. My idea is just to simulate the
>> internet user's process and cache the tiles that are received during
>> that preview process. So the cache may not be perfect but can be used
>> for offline easily. So from where I can manipulate those tiles I want,
>> if I'm using OpenLayer? Or the idea is not feasible?
>
>
> This is exactly what I am suggesting and mapcache handles all that for you
> and it is transparent. There are only two things that you might want to do.
>
> 1. if you know you are going offline and you have some area of interest that
> you want to have tiles locally for, then run the seeder to populate just
> that area of interest.
>
> 2. manage the cache disk space, by deleting tiles that you do not need,
> however you determine that.
>
> What is nice about this solution is that you do not need to make any changes
> to OpenLayers when you change from online to offline.
>
>
> browser -> mapcache -> OSM
>               |
>               V
>             cache
>
> So when you are online, and request a tile, mapcache uses the local copy if
> it exists otherwise if gets it from OSM and caches it.
>
> If you are offline, and request a tile, mapcache uses the local copy if it
> exists otherwise tries to fetch it and fails and return a default NO_TILE
> tile.
>
> Later when you are online again and if you request what was a NO_TILE before
> it will fetch and store the new tile.
>
> So the cache gets populated as it is used unless you decide to run the
> seeder for some area of interest like a bounding box and you have control of
> what zoom levels etc that you want to cache with the seeder.
>
> -Steve
>
>
>
>> Best,
>> Hanks
>>
>> 2012/9/21 Stephen Woodbridge <woodbri at swoodbridge.com>:
>>>
>>> On 9/21/2012 8:53 PM, hz hanks wrote:
>>>>
>>>>
>>>> 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?
>>>
>>>
>>>
>>> This is not a function or capability of OpenLayers, but that said you
>>> might
>>> want to ask this question on the Mapserver.org list regarding mapcache.
>>>
>>> The idea being to set up apache2 on your laptop with mapcache installed
>>> and
>>> configured to pull tiles from OSM, then configure your OpenLayers app to
>>> pull tiles from mapcache. Mapcache will pull and cache the tiles locally
>>> as
>>> they are requested or you can run a seeder that will pre-populate the
>>> tiles.
>>>
>>> There are two problems that I see with this setup:
>>>
>>> 1. unless you have a huge disk you will need to write a script to clean
>>> tiles that you do not need.
>>>
>>> 2. you need to write a script to run the seeder and pull the area of
>>> interest that you are interested in, before you go offline.
>>>
>>> Hope this helps,
>>>    -Steve W
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
>


More information about the Users mailing list