[OpenLayers-Commits] r11536 - trunk/openlayers/lib/OpenLayers

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Fri Feb 25 13:14:35 EST 2011


Author: ahocevar
Date: 2011-02-25 10:14:29 -0800 (Fri, 25 Feb 2011)
New Revision: 11536

Modified:
   trunk/openlayers/lib/OpenLayers/Map.js
Log:
make tween panning use Map::moveByPx. p=aabt, r=me (closes #3098)

Modified: trunk/openlayers/lib/OpenLayers/Map.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Map.js	2011-02-25 18:02:12 UTC (rev 11535)
+++ trunk/openlayers/lib/OpenLayers/Map.js	2011-02-25 18:14:29 UTC (rev 11536)
@@ -1606,31 +1606,25 @@
                 return;
             }
 
-            var from = {
-                lon: center.lon,
-                lat: center.lat
-            };
-            var to = {
-                lon: lonlat.lon,
-                lat: lonlat.lat
-            };
-            this.panTween.start(from, to, this.panDuration, {
+            var from = this.getPixelFromLonLat(center);
+            var to = this.getPixelFromLonLat(lonlat);
+            var vector = { x: to.x - from.x, y: to.y - from.y };
+            var last = { x: 0, y: 0 };
+
+            this.panTween.start( { x: 0, y: 0 }, vector, this.panDuration, {
                 callbacks: {
-                    start: OpenLayers.Function.bind(function(lonlat) {
+                    start: OpenLayers.Function.bind(function() {
                         this.events.triggerEvent("movestart");
                     }, this),
-                    eachStep: OpenLayers.Function.bind(function(lonlat) {
-                        lonlat = new OpenLayers.LonLat(lonlat.lon, lonlat.lat);
-                        this.moveTo(lonlat, this.zoom, {
-                            'dragging': true,
-                            'noEvent': true
-                        });
+                    eachStep: OpenLayers.Function.bind(function(px) {
+                        var x = px.x - last.x,
+                            y = px.y - last.y;
+                        this.moveByPx(x, y);
+                        last.x = Math.round(px.x);
+                        last.y = Math.round(px.y);
                     }, this),
-                    done: OpenLayers.Function.bind(function(lonlat) {
-                        lonlat = new OpenLayers.LonLat(lonlat.lon, lonlat.lat);
-                        this.moveTo(lonlat, this.zoom, {
-                            'noEvent': true
-                        });
+                    done: OpenLayers.Function.bind(function(px) {
+                        this.moveTo(lonlat, this.zoom, {noEvent: true});
                         this.events.triggerEvent("moveend");
                     }, this)
                 }



More information about the Commits mailing list