[OpenLayers-Commits] r12357 - in trunk/openlayers: lib/OpenLayers lib/OpenLayers/Layer lib/OpenLayers/Renderer tests/manual

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Mon Sep 12 00:26:33 EDT 2011


Author: ahocevar
Date: 2011-09-11 21:26:32 -0700 (Sun, 11 Sep 2011)
New Revision: 12357

Modified:
   trunk/openlayers/lib/OpenLayers/Layer.js
   trunk/openlayers/lib/OpenLayers/Layer/Grid.js
   trunk/openlayers/lib/OpenLayers/Layer/XYZ.js
   trunk/openlayers/lib/OpenLayers/Renderer/SVG.js
   trunk/openlayers/tests/manual/dateline-sketch.html
Log:
also consider the resolutions array if no zoomOffset is provided. r=bartvde (closes #3485)

Modified: trunk/openlayers/lib/OpenLayers/Layer/Grid.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/Grid.js	2011-09-11 15:28:03 UTC (rev 12356)
+++ trunk/openlayers/lib/OpenLayers/Layer/Grid.js	2011-09-12 04:26:32 UTC (rev 12357)
@@ -247,7 +247,11 @@
                 //  *partially* contained by our tiles (IE user has 
                 //  programmatically panned to the other side of the earth) 
                 //  then we want to reTile (thus, partial true).  
-                //
+                //                
+                var maxExtent = this.map.getMaxExtent(),
+                    bl = new OpenLayers.LonLat(bounds.left, bounds.bottom).wrapDateLine(maxExtent),
+                    tr = new OpenLayers.LonLat(bounds.right, bounds.top).wrapDateLine(maxExtent);
+                bounds = new OpenLayers.Bounds(bl.lon, bl.lat, tr.lon, tr.lat);
                 if (forceReTile || !tilesBounds.containsBounds(bounds, true)) {
                     this.initGriddedTiles(bounds);
                 } else {

Modified: trunk/openlayers/lib/OpenLayers/Layer/XYZ.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer/XYZ.js	2011-09-11 15:28:03 UTC (rev 12356)
+++ trunk/openlayers/lib/OpenLayers/Layer/XYZ.js	2011-09-12 04:26:32 UTC (rev 12357)
@@ -144,8 +144,9 @@
             (res * this.tileSize.w));
         var y = Math.round((this.maxExtent.top - bounds.top) /
             (res * this.tileSize.h));
-        var z = this.serverResolutions != null ?
-            OpenLayers.Util.indexOf(this.serverResolutions, res) :
+        var resolutions = this.serverResolutions || this.resolutions;
+        var z = this.zoomOffset == 0 ?
+            OpenLayers.Util.indexOf(resolutions, res) :
             this.map.getZoom() + this.zoomOffset;
 
         var limit = Math.pow(2, z);

Modified: trunk/openlayers/lib/OpenLayers/Layer.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer.js	2011-09-11 15:28:03 UTC (rev 12356)
+++ trunk/openlayers/lib/OpenLayers/Layer.js	2011-09-12 04:26:32 UTC (rev 12357)
@@ -297,7 +297,10 @@
 
     /**
      * APIProperty: wrapDateLine
-     * {Boolean} #487 for more info.   
+     * {Boolean} Wraps the world at the international dateline, so the map can
+     * be panned infinitely in longitudinal direction. Only use this on the
+     * base layer, and only if the layer's maxExtent equals the world bounds.
+     * #487 for more info.   
      */
     wrapDateLine: false,
     

Modified: trunk/openlayers/lib/OpenLayers/Renderer/SVG.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Renderer/SVG.js	2011-09-11 15:28:03 UTC (rev 12356)
+++ trunk/openlayers/lib/OpenLayers/Renderer/SVG.js	2011-09-12 04:26:32 UTC (rev 12357)
@@ -133,6 +133,14 @@
             this.translate(0, 0);
             return true;
         } else {
+            var maxExtent = this.map.getMaxExtent(),
+                width = maxExtent.getWidth() / resolution;
+            if (extent.left < maxExtent.left) {
+                extent.left += width;
+            }
+            if (extent.right > maxExtent.right) {
+                extent.left -= width;
+            }
             var inRange = this.translate(left - this.left, top - this.top);
             if (!inRange) {
                 // recenter the coordinate system

Modified: trunk/openlayers/tests/manual/dateline-sketch.html
===================================================================
--- trunk/openlayers/tests/manual/dateline-sketch.html	2011-09-11 15:28:03 UTC (rev 12356)
+++ trunk/openlayers/tests/manual/dateline-sketch.html	2011-09-12 04:26:32 UTC (rev 12357)
@@ -22,18 +22,29 @@
 var map;
 
 function init(){
-    map = new OpenLayers.Map('map');
+    var maxExtent = new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508),
+        maxResolution = 156543.0339;
+    
+    var options = {
+        projection: new OpenLayers.Projection("EPSG:900913"),
+        displayProjection: new OpenLayers.Projection("EPSG:4326"),
+        units: "m",
+        numZoomLevels: 18,
+        maxResolution: maxResolution,
+        maxExtent: maxExtent
+    };
+    map = new OpenLayers.Map('map', options);
 
-    var gmap = new OpenLayers.Layer.Google(
-        "Google Streets",
-        {sphericalMercator: true}
+    var dummy = new OpenLayers.Layer(
+        "dummy",
+        {isBaseLayer: true, wrapDateLine: true}
     );
     var vector = new OpenLayers.Layer.Vector("Editable Vectors");
 
-    map.addLayers([gmap, vector]);
+    map.addLayers([dummy, vector]);
     map.addControl(new OpenLayers.Control.EditingToolbar(vector));
 
-    var extent = new OpenLayers.Bounds(-24225034.496992, -11368938.517442, -14206280.326992, -1350184.3474418);
+    var extent = new OpenLayers.Bounds(15849982.183008, -11368938.517442, -14206280.326992, -1350184.3474418);
     map.zoomToExtent(extent);
 }
 



More information about the Commits mailing list