[GIS] OSM offline tiles — mbtiles in openlayers

mbtilesopenlayersosm2vectortiles

I used tiledownloader to download offline tiles.
Now with the new policy acces of mapquest this would be difficult.

I found http://osm2vectortiles.org/downloads/ to download some files but they are in .mbtiles

How is it possible to work with .mbtiles in openlayers 3? Should i convert them first? In case of yes, how is that possible?

Best Answer

The OSM2VectorTiles link you mentioned offers a download of VECTOR tiles for OpenStreetMap. There are no RASTER .png inside the MBTiles, instead, there are ProtoBuf (PBF) tiles in. This is MBTiles similar to the one generated by MapBox Studio Classic.

If you want raster tiles (PNG/JPEG) for use in OpenLayers or Leaflet, then you need to install a server which turns the vector tiles into raster tiles on demand.

Easiest maybe:

Read the documentation of these tools on how to use them. We at KlokanTech.com have developed these tools to switch from MapQuest and MapBox to our own hosted OpenStreetMaps - and we are releasing it as open-source to anybody. Check our talk at FOSS4G 2016 (late August 2016).

In case you want to use vector tiles directly (the .pbf files) - for example in native mobile apps, MapBox GL JS or OpenLayers (like http://openlayers.org/en/latest/examples/mapbox-vector-tiles.html) then hosting is easier - as you can either simply "unpack" the .pbf from the MBTiles or install a basic utility extracting these files on demand. BTW the vector tiles down to zoom level 14 contains all street data with details of zoomlevel 20).

The example of such utilities:

other approaches are mentioned at Self-hosting Mapbox vector tiles

Related Question