[OpenLayers-Commits] r12283 - sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Mon Aug 29 08:50:36 EDT 2011


Author: erilem
Date: 2011-08-29 05:50:33 -0700 (Mon, 29 Aug 2011)
New Revision: 12283

Modified:
   sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer/Grid.js
Log:
make pan work when in "client zoom" mode

Modified: sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer/Grid.js
===================================================================
--- sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer/Grid.js	2011-08-29 08:37:58 UTC (rev 12282)
+++ sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer/Grid.js	2011-08-29 12:50:33 UTC (rev 12283)
@@ -362,6 +362,17 @@
     },
 
     /**
+     * Method: getResolutionScale
+     * Return the value by which the layer is currently scaled.
+     *
+     * Returns:
+     * {Number} The resolution scale.
+     */
+    getResolutionScale: function() {
+        return parseInt(this.div.style.width) / 100;
+    },
+
+    /**
      * Method: moveByPx
      * Move the layer based on pixel vector.
      *
@@ -370,14 +381,7 @@
      * dy - {Number}
      */
     moveByPx: function(dx, dy) {
-        // do not move schedule move of gridded tiles if in single
-        // tile or client zoom mode
-        // FIXME this must be fixed
-        var resolution = this.map.getResolution();
-        if (!this.singleTile &&
-            (!this.serverResolutions ||
-                             OpenLayers.Util.indexOf(
-                                 this.serverResolutions, resolution) !== -1)) {
+        if (!this.singleTile) {
             this.scheduleMoveGriddedTiles();
         }
     },
@@ -811,17 +815,25 @@
     moveGriddedTiles: function() {
         var shifted = true;
         var buffer = this.buffer || 1;
-        var tlLayer = this.grid[0][0].position;
+        var scale = this.getResolutionScale();
+        var tlLayer = this.grid[0][0].position.clone();
+        tlLayer.x *= scale;
+        tlLayer.y *= scale;
+        tlLayer = tlLayer.add(parseInt(this.div.style.left),
+                              parseInt(this.div.style.top));
         var offsetX = parseInt(this.map.layerContainerDiv.style.left);
         var offsetY = parseInt(this.map.layerContainerDiv.style.top);
         var tlViewPort = tlLayer.add(offsetX, offsetY);
-        if (tlViewPort.x > -this.tileSize.w * (buffer - 1)) {
+        var tileSize = this.tileSize.clone();
+        tileSize.w *= scale;
+        tileSize.h *= scale;
+        if (tlViewPort.x > -tileSize.w * (buffer - 1)) {
             this.shiftColumn(true);
-        } else if (tlViewPort.x < -this.tileSize.w * buffer) {
+        } else if (tlViewPort.x < -tileSize.w * buffer) {
             this.shiftColumn(false);
-        } else if (tlViewPort.y > -this.tileSize.h * (buffer - 1)) {
+        } else if (tlViewPort.y > -tileSize.h * (buffer - 1)) {
             this.shiftRow(true);
-        } else if (tlViewPort.y < -this.tileSize.h * buffer) {
+        } else if (tlViewPort.y < -tileSize.h * buffer) {
             this.shiftRow(false);
         } else {
             shifted = false;
@@ -903,7 +915,7 @@
             }
         }
     },
-    
+
     /**
      * Method: removeExcessTiles
      * When the size of the map or the buffer changes, we may need to



More information about the Commits mailing list