diff --git a/src/source/tile.js b/src/source/tile.js index d1d502cbf11..35aa5ea66cb 100644 --- a/src/source/tile.js +++ b/src/source/tile.js @@ -392,6 +392,8 @@ class Tile { const vtLayers = this.latestFeatureIndex.loadVTLayers(); for (const id in this.buckets) { + if (!painter.style.hasLayer(id)) continue; + const bucket = this.buckets[id]; // Buckets are grouped by common source-layer const sourceLayerId = bucket.layers[0]['sourceLayer'] || '_geojsonTileLayer'; diff --git a/src/style/style.js b/src/style/style.js index 27890d5dcde..d4f99622276 100644 --- a/src/style/style.js +++ b/src/style/style.js @@ -769,6 +769,17 @@ class Style extends Evented { return this._layers[id]; } + /** + * checks if a specific layer is present within the style. + * + * @param {string} id - id of the desired layer + * @returns {boolean} a boolean specifying if the given layer is present + */ + hasLayer(id: string): boolean { + const layerIds = Object.keys(this._layers); + return layerIds.includes(id, 0); + } + setLayerZoomRange(layerId: string, minzoom: ?number, maxzoom: ?number) { this._checkLoaded();