What exactly do the minzoom
and maxzoom
properties on vector tile sources, and vector-based layers do in Mapbox-GL-JS styles? The documentation is a bit short.
A zoom level determines how much of the world is visible on a map. Mapbox provides maps in 23 zoom levels, with 0 being the lowest zoom level (fully zoomed out) and 22 being the highest (fully zoomed in).
Mapbox GL JS is a JavaScript library for vector maps on the Web. Its performance, real-time styling, and interactivity features set the bar for anyone building fast, immersive maps on the web.
A layer references a data source that defines the features that should be appear when the layer is rendered, and it provides styling instructions that describe the visual properties that should be applied to those features when the layer is rendered.
Let's take this example:
"mytiles": {
"type": "vector",
"tiles": ["http://localhost/tiles/{z}/{x}/{y}.pbf"],
"minzoom": 7,
"maxzoom": 12
}
This means:
http://localhost/tiles/tiles.json
(I think), ignore its minzoom
and maxzoom
properties.If minzoom
and/or maxzoom
properties are not defined on the source, the equivalent properties are used from a TileJSON if available. Otherwise, tiles are assumed to be available at any zoom level requested, and no overzooming occurs. (If tiles aren't actually available, they just don't display.)
Let's take this example, referring to the source above:
{
"id": "mylayer",
"source": "mytiles",
"source-layer": "mytiles-layer",
"type": "fill",
"minzoom": 10,
"maxzoom": 14
}
This means:
If minzoom
/maxzoom
properties are not defined, then the layer will attempt to display at any given zoom within the source's zoom range.
For completeness: When instantiating the Map object:
const map = new mapboxgl.Map({
container: 'map,
style,
minZoom: 8, // note the camel-case
maxZoom: 15
});
This means:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With