Don't load an already loading tile
This commit is contained in:
+8
-4
@@ -1,6 +1,7 @@
|
|||||||
goog.provide('ol.TilePriorityFunction');
|
goog.provide('ol.TilePriorityFunction');
|
||||||
goog.provide('ol.TileQueue');
|
goog.provide('ol.TileQueue');
|
||||||
|
|
||||||
|
goog.require('goog.asserts');
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol.Coordinate');
|
||||||
@@ -56,7 +57,7 @@ ol.TileQueue = function(tilePriorityFunction, tileChangeCallback) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Object.<string,boolean>}
|
* @type {!Object.<string,boolean>}
|
||||||
*/
|
*/
|
||||||
this.tilesLoadingKeys_ = {};
|
this.tilesLoadingKeys_ = {};
|
||||||
|
|
||||||
@@ -104,6 +105,7 @@ ol.TileQueue.prototype.handleTileChange = function(event) {
|
|||||||
}
|
}
|
||||||
this.tileChangeCallback_();
|
this.tileChangeCallback_();
|
||||||
}
|
}
|
||||||
|
goog.asserts.assert(Object.keys(this.tilesLoadingKeys_).length === this.tilesLoading_);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -113,15 +115,17 @@ ol.TileQueue.prototype.handleTileChange = function(event) {
|
|||||||
*/
|
*/
|
||||||
ol.TileQueue.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads) {
|
ol.TileQueue.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads) {
|
||||||
var newLoads = 0;
|
var newLoads = 0;
|
||||||
var tile;
|
var tile, tileKey;
|
||||||
while (this.tilesLoading_ < maxTotalLoading && newLoads < maxNewLoads &&
|
while (this.tilesLoading_ < maxTotalLoading && newLoads < maxNewLoads &&
|
||||||
this.getCount() > 0) {
|
this.getCount() > 0) {
|
||||||
tile = /** @type {ol.Tile} */ (this.dequeue()[0]);
|
tile = /** @type {ol.Tile} */ (this.dequeue()[0]);
|
||||||
if (tile.getState() === ol.TileState.IDLE) {
|
tileKey = tile.getKey();
|
||||||
this.tilesLoadingKeys_[tile.getKey()] = true;
|
if (tile.getState() === ol.TileState.IDLE && !(tileKey in this.tilesLoadingKeys_)) {
|
||||||
|
this.tilesLoadingKeys_[tileKey] = true;
|
||||||
++this.tilesLoading_;
|
++this.tilesLoading_;
|
||||||
++newLoads;
|
++newLoads;
|
||||||
tile.load();
|
tile.load();
|
||||||
}
|
}
|
||||||
|
goog.asserts.assert(Object.keys(this.tilesLoadingKeys_).length === this.tilesLoading_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user