[OpenLayers-Commits] r11864 - in trunk/openlayers: examples
lib/OpenLayers/Layer tests/Layer
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Mon Apr 4 03:20:52 EDT 2011
Author: pgiraud
Date: 2011-04-04 00:20:48 -0700 (Mon, 04 Apr 2011)
New Revision: 11864
Modified:
trunk/openlayers/examples/mobile-drawing.js
trunk/openlayers/lib/OpenLayers/Layer/XYZ.js
trunk/openlayers/tests/Layer/XYZ.html
Log:
Adding wrapDateLine support for XYZ layers. The OSM layer now wraps the date line by default. p=tomh, r=me (Closes #2246)
Modified: trunk/openlayers/examples/mobile-drawing.js
===================================================================
--- trunk/openlayers/examples/mobile-drawing.js 2011-04-04 07:19:46 UTC (rev 11863)
+++ trunk/openlayers/examples/mobile-drawing.js 2011-04-04 07:20:48 UTC (rev 11864)
@@ -35,6 +35,9 @@
})
]);
+ var osm = new OpenLayers.Layer.OSM();
+ osm.wrapDateLine = false;
+
map = new OpenLayers.Map({
div: 'map',
projection: 'EPSG:900913',
@@ -53,7 +56,7 @@
new OpenLayers.Control.ZoomPanel(),
toolbar
],
- layers: [new OpenLayers.Layer.OSM(), vector],
+ layers: [osm, vector],
center: new OpenLayers.LonLat(0, 0),
zoom: 1,
theme: null
Modified: trunk/openlayers/lib/OpenLayers/Layer/XYZ.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/XYZ.js 2011-04-04 07:19:46 UTC (rev 11863)
+++ trunk/openlayers/lib/OpenLayers/Layer/XYZ.js 2011-04-04 07:20:48 UTC (rev 11864)
@@ -148,6 +148,12 @@
OpenLayers.Util.indexOf(this.serverResolutions, res) :
this.map.getZoom() + this.zoomOffset;
+ var limit = Math.pow(2, z);
+ if (this.wrapDateLine)
+ {
+ x = ((x % limit) + limit) % limit;
+ }
+
return {'x': x, 'y': y, 'z': z};
},
@@ -199,5 +205,6 @@
obj = OpenLayers.Layer.XYZ.prototype.clone.apply(this, [obj]);
return obj;
},
+ wrapDateLine: true,
CLASS_NAME: "OpenLayers.Layer.OSM"
});
Modified: trunk/openlayers/tests/Layer/XYZ.html
===================================================================
--- trunk/openlayers/tests/Layer/XYZ.html 2011-04-04 07:19:46 UTC (rev 11863)
+++ trunk/openlayers/tests/Layer/XYZ.html 2011-04-04 07:20:48 UTC (rev 11864)
@@ -108,7 +108,7 @@
*/
function test_Layer_XYZ_getURL(t) {
- t.plan(2);
+ t.plan(6);
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.XYZ(name, url);
@@ -120,6 +120,17 @@
layer.url = ["http://tilecache1/", "http://tilecache2/", "http://tilecache3/"];
tileurl = layer.getURL(new OpenLayers.Bounds(3.515625,45,4.21875,45.703125));
t.eq(tileurl, "http://tilecache1/", "Tile URL is deterministic");
+
+ layer.url = url;
+ tileurl = layer.getURL(new OpenLayers.Bounds(180.515625,45,181.21875,45.703125));
+ t.eq(tileurl, "http://labs.metacarta.com/wms-c/Basic.py/1.0.0/basic/9/513/63.png", "Tile URL is correct");
+ tileurl = layer.getURL(new OpenLayers.Bounds(-181.515625,45,-180.21875,45.703125));
+ t.eq(tileurl, "http://labs.metacarta.com/wms-c/Basic.py/1.0.0/basic/9/-2/63.png", "Tile URL is correct");
+ layer.wrapDateLine = true;
+ tileurl = layer.getURL(new OpenLayers.Bounds(180.515625,45,181.21875,45.703125));
+ t.eq(tileurl, "http://labs.metacarta.com/wms-c/Basic.py/1.0.0/basic/9/1/63.png", "Tile URL is correct");
+ tileurl = layer.getURL(new OpenLayers.Bounds(-181.515625,45,-180.21875,45.703125));
+ t.eq(tileurl, "http://labs.metacarta.com/wms-c/Basic.py/1.0.0/basic/9/510/63.png", "Tile URL is correct");
map.destroy();
}
function test_Layer_XYZ_Rounding(t) {
More information about the Commits
mailing list