Make maximum number of tiles loading a parameter to loadMoreTiles

This commit is contained in:
Tom Payne
2013-04-07 18:10:19 +02:00
parent 5f817476c2
commit da6f4cc764
2 changed files with 5 additions and 14 deletions

View File

@@ -304,7 +304,6 @@ ol.Map = function(options) {
* @type {ol.TileQueue} * @type {ol.TileQueue}
*/ */
this.tileQueue_ = new ol.TileQueue( this.tileQueue_ = new ol.TileQueue(
ol.MAXIMUM_TILES_LOADING,
goog.bind(this.getTilePriority, this), goog.bind(this.getTilePriority, this),
goog.bind(this.handleTileChange_, this)); goog.bind(this.handleTileChange_, this));
@@ -598,7 +597,7 @@ ol.Map.prototype.handlePostRender = function() {
} }
this.tileQueue_.reprioritize(); // FIXME only call if needed this.tileQueue_.reprioritize(); // FIXME only call if needed
this.tileQueue_.loadMoreTiles(limit); this.tileQueue_.loadMoreTiles(limit, ol.MAXIMUM_TILES_LOADING);
var postRenderFunctions = this.postRenderFunctions_; var postRenderFunctions = this.postRenderFunctions_;
var i; var i;

View File

@@ -18,15 +18,12 @@ ol.TilePriorityFunction;
/** /**
* @constructor * @constructor
* @extends {ol.structs.PriorityQueue} * @extends {ol.structs.PriorityQueue}
* @param {number} maxTilesLoading Maximum number of simultaneously loading
* tiles.
* @param {ol.TilePriorityFunction} tilePriorityFunction * @param {ol.TilePriorityFunction} tilePriorityFunction
* Tile priority function. * Tile priority function.
* @param {Function} tileChangeCallback * @param {Function} tileChangeCallback
* Function called on each tile change event. * Function called on each tile change event.
*/ */
ol.TileQueue = ol.TileQueue = function(tilePriorityFunction, tileChangeCallback) {
function(maxTilesLoading, tilePriorityFunction, tileChangeCallback) {
goog.base( goog.base(
this, this,
@@ -51,12 +48,6 @@ ol.TileQueue =
*/ */
this.tileChangeCallback_ = tileChangeCallback; this.tileChangeCallback_ = tileChangeCallback;
/**
* @private
* @type {number}
*/
this.maxTilesLoading_ = maxTilesLoading;
/** /**
* @private * @private
* @type {number} * @type {number}
@@ -78,12 +69,13 @@ ol.TileQueue.prototype.handleTileChange = function() {
/** /**
* @param {number} limit Maximum number of new tiles to load. * @param {number} limit Maximum number of new tiles to load.
* @param {number} maxTilesLoading Maximum number tiles to load simultaneously.
*/ */
ol.TileQueue.prototype.loadMoreTiles = function(limit) { ol.TileQueue.prototype.loadMoreTiles = function(limit, maxTilesLoading) {
var tile; var tile;
while (limit > 0 && while (limit > 0 &&
!this.isEmpty() && !this.isEmpty() &&
this.tilesLoading_ < this.maxTilesLoading_) { this.tilesLoading_ < maxTilesLoading) {
tile = /** @type {ol.Tile} */ (this.dequeue()[0]); tile = /** @type {ol.Tile} */ (this.dequeue()[0]);
goog.events.listenOnce(tile, goog.events.EventType.CHANGE, goog.events.listenOnce(tile, goog.events.EventType.CHANGE,
this.handleTileChange, false, this); this.handleTileChange, false, this);