diff --git a/src/index.js b/src/index.js index 1a098b8..b129d35 100644 --- a/src/index.js +++ b/src/index.js @@ -129,8 +129,10 @@ export default class IndoorEqual { /** * Remove any layers, source and listeners and controls */ - remove() { - this.source.remove(); + remove(fromRemoveEvent) { + if (!fromRemoveEvent) { + this.source.remove(); + } this._updateLevelsDebounce.clear(); this.map.off('load', this._updateLevelsDebounce); this.map.off('data', this._updateLevelsDebounce); @@ -247,7 +249,7 @@ export default class IndoorEqual { this.map.on('data', this._updateLevelsDebounce); this.map.on('move', this._updateLevelsDebounce); this.map.on('remove', () => { - this.remove(); + this.remove(true); }); }