Skip to content

Commit

Permalink
Release version 0.2.12.
Browse files Browse the repository at this point in the history
  • Loading branch information
francois2metz committed Feb 17, 2022
1 parent a3ac1be commit b565155
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 14 deletions.
42 changes: 36 additions & 6 deletions dist/mapbox-gl-indoorequal.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,15 @@ class GeoJSONSource {
});
});
}

remove() {
this.layers.forEach((layer) => {
this.map.removeLayer(layer.id);
});
Object.keys(this.geojson).forEach((layerName) => {
this.map.removeSource(`${this.baseSourceId}_${layerName}`);
});
}
}

class VectorTileSource {
Expand Down Expand Up @@ -557,11 +566,18 @@ class VectorTileSource {
});
});
}

remove() {
this.layers.forEach((layer) => {
this.map.removeLayer(layer.id);
});
this.map.removeSource(this.sourceId);
}
}

/**
* Load the indoor= source and layers in your map.
* @param {object} map the mapbox-gl instance of the map
* @param {object} map the mapbox-gl/maplibre-gl instance of the map
* @param {object} options
* @param {string} [options.url] Override the default tiles URL (https://tiles.indoorequal.org/).
* @param {object} [options.geojson] GeoJSON data with with key as layer name and value with geojson features
Expand Down Expand Up @@ -596,6 +612,20 @@ class IndoorEqual {
}
}

/**
* Remove any layers, source and listeners and controls
*/
remove() {
this.source.remove();
this._updateLevelsDebounce.clear();
this.map.off('load', this._updateLevelsDebounce);
this.map.off('data', this._updateLevelsDebounce);
this.map.off('move', this._updateLevelsDebounce);
if (this._control) {
this.onRemove();
}
}

/**
* Add an event listener
* @param {string} name the name of the event
Expand Down Expand Up @@ -697,13 +727,13 @@ class IndoorEqual {
this.source.addSource();
this._addLayers();
this._updateFilters();
const updateLevels = debounce__default["default"](this._updateLevels.bind(this), 1000);
this._updateLevelsDebounce = debounce__default["default"](this._updateLevels.bind(this), 1000);

this.map.on('load', updateLevels);
this.map.on('data', updateLevels);
this.map.on('move', updateLevels);
this.map.on('load', this._updateLevelsDebounce);
this.map.on('data', this._updateLevelsDebounce);
this.map.on('move', this._updateLevelsDebounce);
this.map.on('remove', () => {
updateLevels.clear();
this.remove();
});
}

Expand Down
42 changes: 36 additions & 6 deletions dist/mapbox-gl-indoorequal.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,15 @@ class GeoJSONSource {
});
});
}

remove() {
this.layers.forEach((layer) => {
this.map.removeLayer(layer.id);
});
Object.keys(this.geojson).forEach((layerName) => {
this.map.removeSource(`${this.baseSourceId}_${layerName}`);
});
}
}

class VectorTileSource {
Expand Down Expand Up @@ -550,11 +559,18 @@ class VectorTileSource {
});
});
}

remove() {
this.layers.forEach((layer) => {
this.map.removeLayer(layer.id);
});
this.map.removeSource(this.sourceId);
}
}

/**
* Load the indoor= source and layers in your map.
* @param {object} map the mapbox-gl instance of the map
* @param {object} map the mapbox-gl/maplibre-gl instance of the map
* @param {object} options
* @param {string} [options.url] Override the default tiles URL (https://tiles.indoorequal.org/).
* @param {object} [options.geojson] GeoJSON data with with key as layer name and value with geojson features
Expand Down Expand Up @@ -589,6 +605,20 @@ class IndoorEqual {
}
}

/**
* Remove any layers, source and listeners and controls
*/
remove() {
this.source.remove();
this._updateLevelsDebounce.clear();
this.map.off('load', this._updateLevelsDebounce);
this.map.off('data', this._updateLevelsDebounce);
this.map.off('move', this._updateLevelsDebounce);
if (this._control) {
this.onRemove();
}
}

/**
* Add an event listener
* @param {string} name the name of the event
Expand Down Expand Up @@ -690,13 +720,13 @@ class IndoorEqual {
this.source.addSource();
this._addLayers();
this._updateFilters();
const updateLevels = debounce(this._updateLevels.bind(this), 1000);
this._updateLevelsDebounce = debounce(this._updateLevels.bind(this), 1000);

this.map.on('load', updateLevels);
this.map.on('data', updateLevels);
this.map.on('move', updateLevels);
this.map.on('load', this._updateLevelsDebounce);
this.map.on('data', this._updateLevelsDebounce);
this.map.on('move', this._updateLevelsDebounce);
this.map.on('remove', () => {
updateLevels.clear();
this.remove();
});
}

Expand Down
Loading

0 comments on commit b565155

Please sign in to comment.