diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index fa17b5b023..c592019b2f 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -228,6 +228,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { removeMap: function(map) { if (this.moveTimerId !== null) { window.clearTimeout(this.moveTimerId); + this.moveTimerId = null; } this.clearTileQueue(); if(this.backBufferTimerId !== null) { @@ -325,10 +326,6 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { // if grid is empty or zoom has changed, we *must* re-tile var forceReTile = !this.grid.length || zoomChanged; - if (forceReTile) { - this.clearTileQueue(); - } - // total bounds of the tiles var tilesBounds = this.getTilesBounds(); @@ -436,8 +433,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { if (this.tileQueue.length === 0) { this.clearTileQueue(); } else { - var tile = this.tileQueue.shift(); - tile.draw(true); + this.tileQueue.shift().draw(true); } }, @@ -704,6 +700,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { * bounds - {} */ initSingleTile: function(bounds) { + this.clearTileQueue(); //determine new tile bounds var center = bounds.getCenterLonLat(); @@ -815,6 +812,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { * bounds - {} */ initGriddedTiles:function(bounds) { + this.clearTileQueue(); // work out mininum number of rows and columns; this is the number of // tiles required to cover the viewport plus at least one for panning