diff --git a/src/ol/imagetile.js b/src/ol/imagetile.js index b0fc00dfb5..d62f5516a2 100644 --- a/src/ol/imagetile.js +++ b/src/ol/imagetile.js @@ -136,6 +136,7 @@ ol.ImageTile.prototype.handleImageLoad_ = function() { ol.ImageTile.prototype.load = function() { if (this.state == ol.TileState.IDLE) { this.state = ol.TileState.LOADING; + this.changed(); goog.asserts.assert(goog.isNull(this.imageListenerKeys_)); this.imageListenerKeys_ = [ goog.events.listenOnce(this.image_, goog.events.EventType.ERROR, diff --git a/src/ol/tilequeue.js b/src/ol/tilequeue.js index 668d39683c..68da9ed5fa 100644 --- a/src/ol/tilequeue.js +++ b/src/ol/tilequeue.js @@ -4,6 +4,7 @@ goog.provide('ol.TileQueue'); goog.require('goog.events'); goog.require('goog.events.EventType'); goog.require('ol.Coordinate'); +goog.require('ol.TileState'); goog.require('ol.structs.PriorityQueue'); @@ -67,11 +68,17 @@ ol.TileQueue.prototype.getTilesLoading = function() { /** + * @param {goog.events.Event} event Event. * @protected */ -ol.TileQueue.prototype.handleTileChange = function() { - --this.tilesLoading_; - this.tileChangeCallback_(); +ol.TileQueue.prototype.handleTileChange = function(event) { + var tile = /** @type {ol.Tile} */ (event.target); + var state = tile.getState(); + if (state === ol.TileState.LOADED || state === ol.TileState.ERROR || + state === ol.TileState.EMPTY) { + --this.tilesLoading_; + this.tileChangeCallback_(); + } }; @@ -85,7 +92,7 @@ ol.TileQueue.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads) { var i, tile; for (i = 0; i < newLoads; ++i) { tile = /** @type {ol.Tile} */ (this.dequeue()[0]); - goog.events.listenOnce(tile, goog.events.EventType.CHANGE, + goog.events.listen(tile, goog.events.EventType.CHANGE, this.handleTileChange, false, this); tile.load(); }