Don't queue tiles multiple times.
This results in a smaller queue that we don't have to unqueue from.
This commit is contained in:
@@ -414,7 +414,11 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
|
|||||||
* evt - {Object} Listener argument of the tile's beforedraw event
|
* evt - {Object} Listener argument of the tile's beforedraw event
|
||||||
*/
|
*/
|
||||||
queueTileDraw: function(evt) {
|
queueTileDraw: function(evt) {
|
||||||
this.tileQueue.push(evt.object);
|
var tile = evt.object;
|
||||||
|
if (!~OpenLayers.Util.indexOf(this.tileQueue, tile)) {
|
||||||
|
// queue only if not in queue already
|
||||||
|
this.tileQueue.push(tile);
|
||||||
|
}
|
||||||
if (!this.tileQueueId) {
|
if (!this.tileQueueId) {
|
||||||
this.tileQueueId = OpenLayers.Animation.start(
|
this.tileQueueId = OpenLayers.Animation.start(
|
||||||
OpenLayers.Function.bind(this.drawTileFromQueue, this),
|
OpenLayers.Function.bind(this.drawTileFromQueue, this),
|
||||||
@@ -433,26 +437,10 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
|
|||||||
this.clearTileQueue();
|
this.clearTileQueue();
|
||||||
} else {
|
} else {
|
||||||
var tile = this.tileQueue.shift();
|
var tile = this.tileQueue.shift();
|
||||||
this.unqueueTile(tile);
|
|
||||||
tile.draw(true);
|
tile.draw(true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Method: unqueueTile
|
|
||||||
* Removes all occurrences of a tile from the <tileQueue>.
|
|
||||||
*
|
|
||||||
* Parameters:
|
|
||||||
* tile - {<OpenLayers.Tile>} The tile to remove from the queue
|
|
||||||
*/
|
|
||||||
unqueueTile: function(tile) {
|
|
||||||
for (var i=this.tileQueue.length-1; i>=0; --i) {
|
|
||||||
if (this.tileQueue[i] === tile) {
|
|
||||||
this.tileQueue.splice(i, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: clearTileQueue
|
* Method: clearTileQueue
|
||||||
* Clears the animation queue
|
* Clears the animation queue
|
||||||
@@ -470,7 +458,6 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
|
|||||||
* tile - {<OpenLayers.Tile>}
|
* tile - {<OpenLayers.Tile>}
|
||||||
*/
|
*/
|
||||||
destroyTile: function(tile) {
|
destroyTile: function(tile) {
|
||||||
this.unqueueTile(tile);
|
|
||||||
this.removeTileMonitoringHooks(tile);
|
this.removeTileMonitoringHooks(tile);
|
||||||
tile.destroy();
|
tile.destroy();
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user