diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index 7709510d31..5e23c828fb 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -583,18 +583,16 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { getTilesBounds: function() { var bounds = null; - if (this.grid.length) { - var bottom = this.grid.length - 1; - var bottomLeftTile = this.grid[bottom][0]; - - var right = this.grid[0].length - 1; - var topRightTile = this.grid[0][right]; - - bounds = new OpenLayers.Bounds(bottomLeftTile.bounds.left, - bottomLeftTile.bounds.bottom, - topRightTile.bounds.right, - topRightTile.bounds.top); + var length = this.grid.length; + if (length) { + var bottomLeftTileBounds = this.grid[length - 1][0].bounds, + width = this.grid[0].length * bottomLeftTileBounds.getWidth(), + height = this.grid.length * bottomLeftTileBounds.getHeight(); + bounds = new OpenLayers.Bounds(bottomLeftTileBounds.left, + bottomLeftTileBounds.bottom, + bottomLeftTileBounds.left + width, + bottomLeftTileBounds.bottom + height); } return bounds; },