Mapbox not able to change the style of vector tiles at run time

304 views Asked by At

I am using tippecanoe command line utility to create my application vector tileset. This is creating a directory structure as per the z/x/y coordinates which is perfectly fine. I have a certain group of features(allocated with a layer) which do not need z to be up to 21 zoom level so it's creating the tiles up to zoom-level 14. It is critical in my case to not to waste the memory space by increasing the max-zoom to 21 for certain layer of features.

As per my understanding, mapbox gl-js queries for the vector tiles as per its coordinate space.

So during my zoom-in from 6 to 21, although zoom-level > 14 tile queries are responding with 404, gl-js is adopting the same tile which is available at 14.

The problem is,

For example, If I click on any feature, I need that feature to be highlighted. I am doing it by filtering out the layers as :

 //hiding the current layer
 mapBox.setFilter(currentLayer, ["==",'gid', "_none_"]);

 //showing only the clicked feature by filtering it out with a unique id it has
 mapBox.setFilter(highlightedLayer, ["==",'gid', feature_gid]);

This works as expected for zoom-level < 14 but if zoom-level exceeds 14 (the max-zoom while tile creation) then it is not able to render the tile with applied layer style as it tries to fetch a tile which is not there on my server. So my question is if a source tile at particular zoom level is giving 404 then why not apply the layer style to whichever tile is available at zoom level 14 ?

Any help to solve this problem?

1

There are 1 answers

0
Raphaël Verdier On

This functionality is not supported by mapbox-gl. You need to go back to Tippecanoe and generate the tiles for this zoom level.

Note that you those new tiles can be similar in terms of data as the other zoom levels.

Remember that tiles are like images generated at a precise zoom level. If you zoom in, one tile will be divided in many tiles.