Properly unregister source tile change listeners

This commit is contained in:
Andreas Hocevar
2019-10-15 21:23:37 +02:00
parent 54884314ee
commit 61fc71c30f
2 changed files with 15 additions and 14 deletions

View File

@@ -5,6 +5,7 @@ import {getUid} from './util.js';
import Tile from './Tile.js';
import TileState from './TileState.js';
import {createCanvasContext2D} from './dom.js';
import {unlistenByKey} from './events.js';
/**
@@ -87,6 +88,11 @@ class VectorRenderTile extends Tile {
*/
this.sourceTileGrid_ = sourceTileGrid;
/**
* @type {Array<import("./events.js").EventsKey>}
*/
this.sourceTileListenerKeys = [];
/**
* z of the source tiles of the last getSourceTiles call.
* @type {number}
@@ -109,6 +115,8 @@ class VectorRenderTile extends Tile {
* @inheritDoc
*/
disposeInternal() {
this.sourceTileListenerKeys.forEach(unlistenByKey);
this.sourceTileListenerKeys.length = 0;
this.removeSourceTiles_(this);
for (const key in this.context_) {
const canvas = this.context_[key].canvas;