[GIS] Mapbox GL JS vector tiles show in higher zoom level without enough vector tiles

javascriptmapbox-gl-jswindows

If I have a set of vector tile files that only available to max zoom at 16, how can I show it on the map at zoom 17 or even 18?

Because of the cause of the data, or the amount of the vector tiles in a layer at a zoom level , my vector tiles generating speed is slow or generated vector tiles is unavailable because it may effect the display of the other layers. That is, I may unable to generated enough vector tiles when I needed them.

My map setting:

map = new mapboxgl.Map({
                container: "gmap",
                zoom: 8,
                center: [120.685296,24.136738],
                style: {
                    "version": 8,
                    "layers": [
                        {
                            "id": "TempBaseMap",
                            "type": "background",
                            "paint": {
                                "background-color": "#C0C0C0"
                            },
                            "minzoom": 8
                        }
                    ],
                },
                maxZoom: 18,
                localIdeographFontFamily: "'Microsoft Jhenghei'",
                logoPosition: "top-left"
            });

And I want to add this vector tiles to a layer…

map.addLayer({
                    "id": "Road",
                    "source": {
"type":"vector",
"tiles":["http://(my local machine)/Road/{z}/{x}/{y}.pbf"]
},
                    "source-layer": "Road",
                    "type": "line",
                    "maxNativeZoom": 18,
                    "layout": {"visibility":"visible"},
                    "paint": {},
                    "minzoom": 8
                });

maxNativeZoom seems works with mapbox.js but I feel that it didn't work with mapbox GL JS.

Best Answer

As said by @AndrewHarvey

In you tile-source add maxzoom

"source": { "maxzoom": 16,//add this line "type":"vector", "tiles":["http://(my local machine)/Road/{z}/{x}/{y}.pbf"] }

Setting max zoom level in source will tell mapbox-gl to over zoom after that zlevel else it will query for the source at all zoom levels

Related Question