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:
@@ -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;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user