Skip to content

Commit

Permalink
Don't place layers hidden by min/maxzoom constraints.
Browse files Browse the repository at this point in the history
Fixes issue mapbox#5776.
  • Loading branch information
ChrisLoer committed Jan 10, 2018
1 parent 5e44e62 commit 1d5408d
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/style/pauseable_placement.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ class PauseablePlacement {
while (this._currentPlacementIndex >= 0) {
const layerId = order[this._currentPlacementIndex];
const layer = layers[layerId];
if (layer.type === 'symbol') {
const placementZoom = this.placement.collisionIndex.transform.zoom;
if (layer.type === 'symbol' &&
(!layer.minzoom || layer.minzoom <= placementZoom) &&
(!layer.maxzoom || layer.maxzoom >= placementZoom)) {

if (!this._inProgressLayer) {
this._inProgressLayer = new LayerPlacement();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"version": 8,
"metadata": {
"test": {
"width": 256,
"height": 256
}
},
"center": [
0,
0
],
"zoom": 0.5,
"glyphs": "local://glyphs/{fontstack}/{range}.pbf",
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "MultiPoint",
"coordinates": [
[
0,
0
]
]
}
}
},
"layers": [
{
"id": "background",
"type": "background",
"paint": {
"background-color": "white"
}
},
{
"id": "bottom",
"type": "symbol",
"source": "geojson",
"layout": {
"text-field": "Bottom Layer",
"text-font": [
"Open Sans Semibold",
"Arial Unicode MS Bold"
]
},
"paint": {
"text-color": "black"
}
},
{
"id": "middle",
"type": "symbol",
"source": "geojson",
"minzoom": 0.8,
"layout": {
"text-field": "Middle Minzoom Layer",
"text-font": [
"Open Sans Semibold",
"Arial Unicode MS Bold"
]
},
"paint": {
"text-color": "blue"
}
},
{
"id": "top",
"type": "symbol",
"source": "geojson",
"maxzoom": 0.3,
"layout": {
"text-field": "Top Maxzoom Layer",
"text-font": [
"Open Sans Semibold",
"Arial Unicode MS Bold"
]
},
"paint": {
"text-color": "blue"
}
}
]
}

0 comments on commit 1d5408d

Please sign in to comment.