[GIS] How to create local map tiles for OpenLayers 2 offline use

offlineopenlayers-2tiles

I have to use my OpenLayers 2 map in an offline stand-alone mode (PC/Laptop disconnected from network).

What is the best way to allow easy capture of map tiles for a region of interest, load them onto the offline laptop and have the OpenLayers 2 map see/use them as its imagery tiles?

Best Answer

You can for example use Tilemill and Mbutil to create offline tiles:

https://www.mapbox.com/tilemill/ (There is already a successor of it called Mapbox Studio but this software still seems to have problems creating offline tiles with mbutils).

https://github.com/mapbox/mbutil

In the OpenStreetMap-Wiki there is also a example of how to use offline tiles: https://wiki.openstreetmap.org/wiki/OpenLayers_Local_Tiles_Example

Basically you can use OpenLayers.Layer.OSM for tiles in spherical mercator:

new OpenLayers.Layer.OSM("Local Tiles", "tiles/${z}/${x}/${y}.png")

or OpenLayers.Layer.XYZ for different projections

new OpenLayers.Layer.XYZ("Local Tiles", "tiles/${z}/${x}/${y}.png")