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

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Aug 31 10:14:47 EDT 2011


Author: erilem
Date: 2011-08-31 07:14:47 -0700 (Wed, 31 Aug 2011)
New Revision: 12303

Modified:
   sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer/Grid.js
Log:
introduce a recenterTiles in Layer.Grid, to call after scaling and retiling

Modified: sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer/Grid.js
===================================================================
--- sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer/Grid.js	2011-08-31 11:42:34 UTC (rev 12302)
+++ sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer/Grid.js	2011-08-31 14:14:47 UTC (rev 12303)
@@ -264,13 +264,7 @@
                 //
                 if (forceReTile || !tilesBounds.containsBounds(bounds, true)) {
                     this.initGriddedTiles(bounds);
-                    // FIXME we need to reposition the layer div, for some
-                    // reason
-                    var size = this.map.getSize();
-                    var origin = this.map.getLayerPxFromViewPortPx(
-                        new OpenLayers.Pixel(size.w / 2, size.h / 2));
-                    this.div.style.left = -origin.x + '%';
-                    this.div.style.top = -origin.y + '%';
+                    this.recenterTiles();
                 } else {
                     this.scheduleMoveGriddedTiles();
                 }
@@ -346,20 +340,31 @@
      */
     transformDiv: function(scale) {
 
-        // scale the layer div with the map center as the
-        // origin
+        // scale the layer div
 
         this.div.style.width = 100 * scale + '%';
         this.div.style.height = 100 * scale + '%';
 
+        // and translate the layer div as necessary
+
+        this.recenterTiles();
+    },
+
+    /**
+     * Method: rencenterTiles
+     * After scaling the layer div or retiling the tiles aren't correctly
+     * positioned. This function moves the layer div to move the* tiles to
+     * the correct position.
+     */
+    recenterTiles: function() {
         var size = this.map.getSize();
         var origin = this.map.getLayerPxFromViewPortPx(
             new OpenLayers.Pixel(size.w / 2, size.h / 2));
-
         this.div.style.left = -origin.x + '%';
         this.div.style.top = -origin.y + '%';
     },
 
+
     /**
      * Method: getResolutionScale
      * Return the value by which the layer is currently scaled.



More information about the Commits mailing list