diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index 696d6e92cf..56d5cfb8e4 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -404,15 +404,9 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { */ calculateGridLayout: function(bounds, origin, resolution) { bounds = bounds.clone(); - if (this.map.baseLayer.wrapDateLine) { - var maxExtent = this.map.getMaxExtent(), - width = maxExtent.getWidth(); - // move the bounds one world width to the right until the origin is - // within the world extent - while (bounds.left < maxExtent.left) { - bounds.left += width; - bounds.right += width; - } + var map = this.map; + if (map.wrapDateLine) { + bounds = bounds.wrapDateLine(map.getMaxExtent()); } var tilelon = resolution * this.tileSize.w;