[OpenLayers-Commits] r2295 - in sandbox/emanuel/animatedZooming/lib/OpenLayers: . Control

commits at openlayers.org commits at openlayers.org
Fri Mar 2 06:00:21 EST 2007


Author: emanuel
Date: 2007-03-02 06:00:20 -0500 (Fri, 02 Mar 2007)
New Revision: 2295

Modified:
   sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/MouseDefaults.js
   sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/MouseToolbar.js
   sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/OverviewMap.js
   sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer.js
Log:
overviewmap bug fixed, animated panning in ovmap

Modified: sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/MouseDefaults.js
===================================================================
--- sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/MouseDefaults.js	2007-03-02 07:52:50 UTC (rev 2294)
+++ sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/MouseDefaults.js	2007-03-02 11:00:20 UTC (rev 2295)
@@ -77,14 +77,9 @@
         // pan to new center   
         var deltaX = evt.xy.x - centerPx.x; 
         var deltaY = evt.xy.y - centerPx.y; 
-        // some problems if you pan AND zoom in the same time... TODO
         this.map.pan(deltaX, deltaY,true);
 
-        // 1. jump to new center (no pan animation!)
-        var newCenter = this.map.getLonLatFromViewPortPx( evt.xy ); 
-        //this.map.setCenter(newCenter, this.map.zoom);
-               
-        // 2. zoom to new level 
+        // zoom to new level 
         this.map.zoomIn(); 
 
         OpenLayers.Event.stop(evt);

Modified: sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/MouseToolbar.js
===================================================================
--- sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/MouseToolbar.js	2007-03-02 07:52:50 UTC (rev 2294)
+++ sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/MouseToolbar.js	2007-03-02 11:00:20 UTC (rev 2295)
@@ -118,18 +118,11 @@
         // pan to new center   
         var deltaX = evt.xy.x - centerPx.x; 
         var deltaY = evt.xy.y - centerPx.y; 
-        // some problems if you pan AND zoom in the same time... TODO
         this.map.pan(deltaX, deltaY,true);
 
-        // jump to new center (no pan animation!)
-        var newCenter = this.map.getLonLatFromViewPortPx( evt.xy ); 
-        //this.map.setCenter(newCenter, this.map.zoom);
+        // zoom to new level 
+        this.map.zoomIn();        
 
-        // get tile below mouseposition
-        var targetTile = evt.target;
-        // 2. zoom to new level 
-        this.map.zoomIn(targetTile);        
-
         OpenLayers.Event.stop(evt);
         return false;
     },

Modified: sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/OverviewMap.js
===================================================================
--- sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/OverviewMap.js	2007-03-02 07:52:50 UTC (rev 2294)
+++ sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/OverviewMap.js	2007-03-02 11:00:20 UTC (rev 2295)
@@ -298,11 +298,11 @@
         newTop = Math.min(newTop, this.ovmap.size.h - height);
         var newLeft = Math.max(0, (left + deltaX));
         newLeft = Math.min(newLeft, this.ovmap.size.w - width);
-        this.setRectPxBounds(new OpenLayers.Bounds(newLeft,
+        pxBounds = new OpenLayers.Bounds(newLeft,
                                                    newTop + height,
                                                    newLeft + width,
-                                                   newTop));
-        this.updateMapToRect();
+                                                   newTop);
+        this.updateMapToRect(pxBounds);
         OpenLayers.Event.stop(evt);
     },
 
@@ -428,10 +428,22 @@
     /**
      * Updates the map extent to match the extent rectangle position and size
      */
-    updateMapToRect: function() {
-        var pxBounds = this.getRectPxBounds();
+    updateMapToRect: function(pxBounds) {
+        if (!pxBounds)
+            var pxBounds = this.getRectPxBounds();
         var lonLatBounds = this.getMapBoundsFromRectBounds(pxBounds);
-        this.map.setCenter(lonLatBounds.getCenterLonLat(), this.map.zoom);
+
+        var centerPx = this.map.getViewPortPxFromLonLat(lonLatBounds.getCenterLonLat());
+
+        var resolution = this.map.getResolution();
+        
+        var width = lonLatBounds.getWidth();
+        width = width / resolution;
+        var height = lonLatBounds.getHeight();
+        height = height / resolution;
+
+        // pan to recenter rectangle
+        this.map.pan(centerPx.x-width/2,centerPx.y-height/2);
     },
     
     /**

Modified: sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer.js
===================================================================
--- sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer.js	2007-03-02 07:52:50 UTC (rev 2294)
+++ sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer.js	2007-03-02 11:00:20 UTC (rev 2295)
@@ -529,8 +529,8 @@
             var center = this.map.getCenter();
             var res  = this.map.getResolution();
             
-            var delta_x = viewPortPx.x - Math.ceil((size.w / 2));
-            var delta_y = viewPortPx.y - Math.ceil((size.h / 2));
+            var delta_x = viewPortPx.x - Math.ceil(size.w / 2);
+            var delta_y = viewPortPx.y - Math.ceil(size.h / 2);
             
             lonlat = new OpenLayers.LonLat(center.lon + delta_x * res ,
                                          center.lat - delta_y * res); 
@@ -690,19 +690,22 @@
      *
      */
     cloneLayerContainer_share:function() {
-         // 1. clone layerContainerDiv with all childs (replace, if already exist)
-        if (this.map.layerContainerDivClone){
-            this.map.viewPortDiv.removeChild(this.map.layerContainerDivClone);
-            this.map.layerContainerDivClone = null;
+        
+        // function for map only; not for overviewmap!
+        if (this.map.div.id == "map") {  
+            // 1. clone layerContainerDiv with all childs (replace, if already exist)
+            if (this.map.layerContainerDivClone){
+                this.map.viewPortDiv.removeChild(this.map.layerContainerDivClone);
+                this.map.layerContainerDivClone = null;
+            }
+            this.map.layerContainerDivClone = this.map.layerContainerDiv.cloneNode(true);
+            this.map.layerContainerDivClone.id = "map_OpenLayers_Container_clone";
+            // 2. append layerContainerDivClone to viewPortDiv
+            // (now the cloned div is above the original; it hides the original)
+            this.map.viewPortDiv.appendChild(this.map.layerContainerDivClone);
+            
+            this.map.layerContainerDiv.style.display= "none";
         }
-        this.map.layerContainerDivClone = this.map.layerContainerDiv.cloneNode(true);
-        this.map.layerContainerDivClone.id = "map_OpenLayers_Container_clone";
-        // 2. append layerContainerDivClone to viewPortDiv
-        // (now the cloned div is above the original; it hides the original)
-        this.map.viewPortDiv.appendChild(this.map.layerContainerDivClone);
-        
-        this.map.layerContainerDiv.style.display= "none";
-
     },
 
 



More information about the Commits mailing list