diff --git a/lib/OpenLayers/Renderer/Elements.js b/lib/OpenLayers/Renderer/Elements.js index fe24292326..4fe85f8a54 100644 --- a/lib/OpenLayers/Renderer/Elements.js +++ b/lib/OpenLayers/Renderer/Elements.js @@ -387,12 +387,11 @@ OpenLayers.Renderer.Elements = OpenLayers.Class(OpenLayers.Renderer, { /** * Property: rightOfDateLine - * {Boolean} Keeps track of the location of the map extent's center - * relative to the date line. The method compares this value - * (which is the one from the previous call) with the current - * position of the map extent relative to the date line and updates the - * xOffset when the extent's center has moved from one side of the date - * line to the other. + * {Boolean} Keeps track of the location of the map extent relative to the + * date line. The method compares this value (which is the one + * from the previous call) with the current position of the map + * extent relative to the date line and updates the xOffset when the extent + * has moved from one side of the date line to the other. */ /** diff --git a/tests/Renderer.html b/tests/Renderer.html index a149d63746..be085f2d60 100644 --- a/tests/Renderer.html +++ b/tests/Renderer.html @@ -24,6 +24,7 @@ t.plan(2); var r = new OpenLayers.Renderer(); + r.map = {}; var extent = new OpenLayers.Bounds(1,2,3,4); r.resolution = 1; r.setExtent(extent, true); diff --git a/tests/Renderer/Elements.html b/tests/Renderer/Elements.html index 48db70adf0..c38c0376a0 100644 --- a/tests/Renderer/Elements.html +++ b/tests/Renderer/Elements.html @@ -616,7 +616,40 @@ tearDown(); } - + function test_setExtent(t) { + t.plan(10); + setUp(); + var resolution = 1; + var r = create_renderer(); + r.map = { + getMaxExtent: function() { + return new OpenLayers.Bounds(-180,-90,180,90); + }, + getResolution: function() { + return resolution; + }, + baseLayer: {wrapDateLine: true} + } + + r.setExtent(new OpenLayers.Bounds(179, -1, 182, 1), true); + t.eq(r.rightOfDateLine, true, "on the right side of the dateline"); + t.eq(r.xOffset, r.map.getMaxExtent().getWidth(), "correct xOffset"); + r.setExtent(new OpenLayers.Bounds(179.5, -1, 182.5, 1), false); + t.eq(r.rightOfDateLine, true, "still on the right side of the dateline"); + t.eq(r.xOffset, r.map.getMaxExtent().getWidth(), "still correct xOffset"); + resolution = 2; + r.setExtent(new OpenLayers.Bounds(178, -2, 184, 2), true); + t.eq(r.rightOfDateLine, true, "still on the right side of the dateline"); + t.eq(r.xOffset, r.map.getMaxExtent().getWidth() / resolution, "xOffset adjusted for new resolution"); + r.setExtent(new OpenLayers.Bounds(-184, -2, 178, 2), false); + t.eq(r.rightOfDateLine, false, "on the left side of the dateline"); + t.eq(r.xOffset, 0, "no xOffset"); + r.setExtent(new OpenLayers.Bounds(178, -2, 184, 2), true); + t.eq(r.rightOfDateLine, true, "back on the right side of the dateline"); + t.eq(r.xOffset, r.map.getMaxExtent().getWidth() / resolution, "correct xOffset"); + + tearDown(); + }