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

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Aug 31 02:49:33 EDT 2011


Author: erilem
Date: 2011-08-30 23:49:32 -0700 (Tue, 30 Aug 2011)
New Revision: 12289

Modified:
   sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer/Grid.js
Log:
correct the transformDiv function, by using the map center as the scale origin

Modified: sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer/Grid.js
===================================================================
--- sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer/Grid.js	2011-08-30 20:22:20 UTC (rev 12288)
+++ sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer/Grid.js	2011-08-31 06:49:32 UTC (rev 12289)
@@ -345,27 +345,18 @@
         // - serverResolutions should be documented
         //
 
-        // scale the layer div
+        // scale the layer div with the map center as the
+        // origin
 
         this.div.style.width = 100 * scale + '%';
         this.div.style.height = 100 * scale + '%';
 
-        // translate the layer div
+        var size = this.map.getSize();
+        var origin = this.map.getLayerPxFromViewPortPx(
+            new OpenLayers.Pixel(size.w / 2, size.h / 2));
 
-        var tilesBounds = this.getTilesBounds();
-        var lonlat = {lon: tilesBounds.left,
-                      lat: tilesBounds.top};
-        var pos = this.map.getPixelFromLonLat(lonlat);
-
-        // when scaling the layer div the tiles were scaled *and* moved, we
-        // need to take this move into account for the positioning of the
-        // layer div
-        var topLeftTile = this.grid[0][0].getTile();
-        var offsetX = parseInt(topLeftTile.style.left, 10) * scale;
-        var offsetY = parseInt(topLeftTile.style.top, 10) * scale;
-
-        this.div.style.left = (pos.x - offsetX) + '%';
-        this.div.style.top = (pos.y - offsetY) + '%';
+        this.div.style.left = -origin.x + '%';
+        this.div.style.top = -origin.y + '%';
     },
 
     /**



More information about the Commits mailing list