diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index 80981a1b1a..1f8a174f9d 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -146,14 +146,16 @@ OpenLayers.Layer.Grid.prototype = this._initTiles(); } else { while (true) { - var topLeft = this.map.getViewPortPxFromLayerPx( this.grid[0][0].position ); - if (topLeft.x > -this.tileSize.w * (this.buffer - 1)) { + var tlLayer = this.grid[0][0].position; + var tlViewPort = + this.map.getViewPortPxFromLayerPx(tlLayer); + if (tlViewPort.x > -this.tileSize.w * (this.buffer - 1)) { this.shiftColumn(true); - } else if (topLeft.x < -this.tileSize.w * this.buffer) { + } else if (tlViewPort.x < -this.tileSize.w * this.buffer) { this.shiftColumn(false); - } else if (topLeft.y > -this.tileSize.w * (this.buffer - 1)) { + } else if (tlViewPort.y > -this.tileSize.w * (this.buffer - 1)) { this.shiftRow(true); - } else if (topLeft.y < -this.tileSize.h * this.buffer) { + } else if (tlViewPort.y < -this.tileSize.h * this.buffer) { this.shiftRow(false); } else { break;