Search code examples
mapbox-gl-jsopenmaptiles

Open Map Tiles with mapbox-gl-js gives error at higher zooms


Using Open Map Tiles with mapbox gl js, when zooming higher than zoom 14 I get errors in the browser console:

mapbox-gl.js?d5ed:510 Error: Error
    at Actor.receive (mapbox-gl.js?d5ed:490)
Evented.fire @ mapbox-gl.js?d5ed:510
Evented.fire @ mapbox-gl.js?d5ed:510
Evented.fire @ mapbox-gl.js?d5ed:510
t._tileLoaded @ mapbox-gl.js?d5ed:222
i @ mapbox-gl.js?d5ed:230
Actor.receive @ mapbox-gl.js?d5ed:490

This fiddle shows this behavior. Please fill in your own OMT key and then it works. The error is [object Error] { ... } it show everywhere zooming above zoom 14 and in some areas already above zoom 11.

I am pretty sure it relates to no tiles being available, however this should simple extend features of zoom 14 instead of giving an error, I would think. What is causing and how can I get rid of these errors?


Solution

  • When you create a tile based source (raster or vector) with mapbox-gl you can define minzoom & maxzoom levels. If set correctly mapbox won't request tiles above/below those levels, but will still show tiles with the biggest/lowest zoom level available:

    map.addSource({
      tiles: [/* tile urls */],
      maxzoom: 11,
      // etc...
    });