Skip to content

Commit fe2e2a8

Browse files
sgolbabaeimike-unearth
authored andcommitted
Clearing the underlying source's tiles while removing a layer. (mapbox#9305)
* clearing the underlying source's tiles while removing a layer. * Removing the clear command since this is computationally expensive and also causing a glitch on the map once the tiles are cleared. * Changing the name of the function to hasLayer to be more specific regarding the function
1 parent 1770b41 commit fe2e2a8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/source/tile.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ class Tile {
392392
const vtLayers = this.latestFeatureIndex.loadVTLayers();
393393

394394
for (const id in this.buckets) {
395+
if (!painter.style.hasLayer(id)) continue;
396+
395397
const bucket = this.buckets[id];
396398
// Buckets are grouped by common source-layer
397399
const sourceLayerId = bucket.layers[0]['sourceLayer'] || '_geojsonTileLayer';

src/style/style.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,17 @@ class Style extends Evented {
769769
return this._layers[id];
770770
}
771771

772+
/**
773+
* checks if a specific layer is present within the style.
774+
*
775+
* @param {string} id - id of the desired layer
776+
* @returns {boolean} a boolean specifying if the given layer is present
777+
*/
778+
hasLayer(id: string): boolean {
779+
const layerIds = Object.keys(this._layers);
780+
return layerIds.includes(id, 0);
781+
}
782+
772783
setLayerZoomRange(layerId: string, minzoom: ?number, maxzoom: ?number) {
773784
this._checkLoaded();
774785

0 commit comments

Comments
 (0)