Don't rely on the bounds of the top-right tile.

When the grid crosses the dateline, the top-right tile is in a different world than the bottom-left one. Instead, use the grid size and tile width/height to calculate the top-right coordinate.
This commit is contained in:
ahocevar
2011-12-03 00:05:26 +01:00
parent c15631ae3e
commit 84b30d3699

View File

@@ -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;
},