[GIS] Load vector tiles (pbf) directly from mbtiles database using OpenLayers 3

mbtilesopenlayersosm2vectortilesvector-tiles

In response to the answer of Klokan Technologies in this thread: OSM offline tiles — mbtiles in openlayers. I managed to unpack a random small mbtiles vector tile map from osm2vectortiles.org and load it locally in a browser using npm http-server, based on this OpenLayers example. However I still have a question:

In the previous answer it is mentioned that the vector tiles down to zoom level 14 contains all street data with details of zoom level 20. However, when I zoom in to level 15+ I get (of course) HTTP 404 file not found errors. I can limit the zoom by setting tileGrid: ol.tilegrid.createXYZ({maxZoom: 14}) but then the map gets blurry at zoom level 15+. How can I utilize the data in zoom level 14 for higher zoom levels?

Best Answer

It was report to Openlayers issues and closed.

Ensure that you are using Openlayers v4.2+. I was using v3.18 and faced similar issue, once upgraded to v4.3.1, resolved my issue. Follow the steps at here and don't increase the 'maxZoom' value from 14 in this code

var tilegrid = ol.tilegrid.createXYZ({tileSize: 512, maxZoom: 14});

Openlayers will manage with tiles of Zoom level 14 to be used at higher zoom levels.

Related Question