Greedify the queue loading strategy

This commit is contained in:
Alessandro Isaacs
2015-07-10 12:03:01 -07:00
parent 5149889bd2
commit 2142b538ac
2 changed files with 12 additions and 22 deletions

View File

@@ -89,16 +89,17 @@ ol.TileQueue.prototype.handleTileChange = function(event) {
* @param {number} maxNewLoads Maximum number of new tiles to load.
*/
ol.TileQueue.prototype.loadMoreTiles = function(maxTotalLoading, maxNewLoads) {
var newLoads = Math.min(
maxTotalLoading - this.getTilesLoading(), maxNewLoads, this.getCount());
var i, tile;
for (i = 0; i < newLoads; ++i) {
var newLoads = 0;
var tile;
while (this.tilesLoading_ < maxTotalLoading && newLoads < maxNewLoads &&
this.getCount() > 0) {
tile = /** @type {ol.Tile} */ (this.dequeue()[0]);
if (tile.getState() === ol.TileState.IDLE) {
goog.events.listen(tile, goog.events.EventType.CHANGE,
this.handleTileChange, false, this);
tile.load();
++this.tilesLoading_;
++newLoads;
}
}
};