Unregister tile change listeners

When the tile queue loads a tile it registers a "change" listener on that tile. But currently that listener is not unregistered, unless the tile cache containing that tile fills up and "dipose" is called on that tile.

This commit makes handleTileChange deregister the "change" listener on the tile, if the tile is now in "loaded" state.
This commit is contained in:
Éric Lemoine
2015-03-30 16:54:09 +02:00
parent 192c9d697e
commit f1d7e2ec85

View File

@@ -76,6 +76,8 @@ ol.TileQueue.prototype.handleTileChange = function(event) {
var state = tile.getState();
if (state === ol.TileState.LOADED || state === ol.TileState.ERROR ||
state === ol.TileState.EMPTY) {
goog.events.unlisten(tile, goog.events.EventType.CHANGE,
this.handleTileChange, false, this);
--this.tilesLoading_;
this.tileChangeCallback_();
}