Fire change event every time state changes
This commit is contained in:
@@ -136,6 +136,7 @@ ol.ImageTile.prototype.handleImageLoad_ = function() {
|
|||||||
ol.ImageTile.prototype.load = function() {
|
ol.ImageTile.prototype.load = function() {
|
||||||
if (this.state == ol.TileState.IDLE) {
|
if (this.state == ol.TileState.IDLE) {
|
||||||
this.state = ol.TileState.LOADING;
|
this.state = ol.TileState.LOADING;
|
||||||
|
this.changed();
|
||||||
goog.asserts.assert(goog.isNull(this.imageListenerKeys_));
|
goog.asserts.assert(goog.isNull(this.imageListenerKeys_));
|
||||||
this.imageListenerKeys_ = [
|
this.imageListenerKeys_ = [
|
||||||
goog.events.listenOnce(this.image_, goog.events.EventType.ERROR,
|
goog.events.listenOnce(this.image_, goog.events.EventType.ERROR,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ goog.provide('ol.TileQueue');
|
|||||||
goog.require('goog.events');
|
goog.require('goog.events');
|
||||||
goog.require('goog.events.EventType');
|
goog.require('goog.events.EventType');
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol.Coordinate');
|
||||||
|
goog.require('ol.TileState');
|
||||||
goog.require('ol.structs.PriorityQueue');
|
goog.require('ol.structs.PriorityQueue');
|
||||||
|
|
||||||
|
|
||||||
@@ -67,11 +68,17 @@ ol.TileQueue.prototype.getTilesLoading = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param {goog.events.Event} event Event.
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
ol.TileQueue.prototype.handleTileChange = function() {
|
ol.TileQueue.prototype.handleTileChange = function(event) {
|
||||||
--this.tilesLoading_;
|
var tile = /** @type {ol.Tile} */ (event.target);
|
||||||
this.tileChangeCallback_();
|
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;
|
var i, tile;
|
||||||
for (i = 0; i < newLoads; ++i) {
|
for (i = 0; i < newLoads; ++i) {
|
||||||
tile = /** @type {ol.Tile} */ (this.dequeue()[0]);
|
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);
|
this.handleTileChange, false, this);
|
||||||
tile.load();
|
tile.load();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user