OpenLayers OpenLayers

Changeset 2295

Show
Ignore:
Timestamp:
03/02/07 06:00:20 (2 years ago)
Author:
emanuel
Message:

overviewmap bug fixed, animated panning in ovmap

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/MouseDefaults.js

    r2292 r2295  
    7878        var deltaX = evt.xy.x - centerPx.x;  
    7979        var deltaY = evt.xy.y - centerPx.y;  
    80         // some problems if you pan AND zoom in the same time... TODO 
    8180        this.map.pan(deltaX, deltaY,true); 
    8281 
    83         // 1. jump to new center (no pan animation!) 
    84         var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );  
    85         //this.map.setCenter(newCenter, this.map.zoom); 
    86                 
    87         // 2. zoom to new level  
     82        // zoom to new level  
    8883        this.map.zoomIn();  
    8984 
  • sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/MouseToolbar.js

    r2292 r2295  
    119119        var deltaX = evt.xy.x - centerPx.x;  
    120120        var deltaY = evt.xy.y - centerPx.y;  
    121         // some problems if you pan AND zoom in the same time... TODO 
    122121        this.map.pan(deltaX, deltaY,true); 
    123122 
    124         // jump to new center (no pan animation!) 
    125         var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );  
    126         //this.map.setCenter(newCenter, this.map.zoom); 
    127  
    128         // get tile below mouseposition 
    129         var targetTile = evt.target; 
    130         // 2. zoom to new level  
    131         this.map.zoomIn(targetTile);         
     123        // zoom to new level  
     124        this.map.zoomIn();         
    132125 
    133126        OpenLayers.Event.stop(evt); 
  • sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/OverviewMap.js

    r2280 r2295  
    299299        var newLeft = Math.max(0, (left + deltaX)); 
    300300        newLeft = Math.min(newLeft, this.ovmap.size.w - width); 
    301         this.setRectPxBounds(new OpenLayers.Bounds(newLeft, 
     301        pxBounds = new OpenLayers.Bounds(newLeft, 
    302302                                                   newTop + height, 
    303303                                                   newLeft + width, 
    304                                                    newTop))
    305         this.updateMapToRect(); 
     304                                                   newTop)
     305        this.updateMapToRect(pxBounds); 
    306306        OpenLayers.Event.stop(evt); 
    307307    }, 
     
    429429     * Updates the map extent to match the extent rectangle position and size 
    430430     */ 
    431     updateMapToRect: function() { 
    432         var pxBounds = this.getRectPxBounds(); 
     431    updateMapToRect: function(pxBounds) { 
     432        if (!pxBounds) 
     433            var pxBounds = this.getRectPxBounds(); 
    433434        var lonLatBounds = this.getMapBoundsFromRectBounds(pxBounds); 
    434         this.map.setCenter(lonLatBounds.getCenterLonLat(), this.map.zoom); 
     435 
     436        var centerPx = this.map.getViewPortPxFromLonLat(lonLatBounds.getCenterLonLat()); 
     437 
     438        var resolution = this.map.getResolution(); 
     439         
     440        var width = lonLatBounds.getWidth(); 
     441        width = width / resolution; 
     442        var height = lonLatBounds.getHeight(); 
     443        height = height / resolution; 
     444 
     445        // pan to recenter rectangle 
     446        this.map.pan(centerPx.x-width/2,centerPx.y-height/2); 
    435447    }, 
    436448     
  • sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer.js

    r2292 r2295  
    530530            var res  = this.map.getResolution(); 
    531531             
    532             var delta_x = viewPortPx.x - Math.ceil((size.w / 2)); 
    533             var delta_y = viewPortPx.y - Math.ceil((size.h / 2)); 
     532            var delta_x = viewPortPx.x - Math.ceil(size.w / 2); 
     533            var delta_y = viewPortPx.y - Math.ceil(size.h / 2); 
    534534             
    535535            lonlat = new OpenLayers.LonLat(center.lon + delta_x * res , 
     
    691691     */ 
    692692    cloneLayerContainer_share:function() { 
    693          // 1. clone layerContainerDiv with all childs (replace, if already exist) 
    694         if (this.map.layerContainerDivClone){ 
    695             this.map.viewPortDiv.removeChild(this.map.layerContainerDivClone); 
    696             this.map.layerContainerDivClone = null; 
    697         } 
    698         this.map.layerContainerDivClone = this.map.layerContainerDiv.cloneNode(true); 
    699         this.map.layerContainerDivClone.id = "map_OpenLayers_Container_clone"; 
    700         // 2. append layerContainerDivClone to viewPortDiv 
    701         // (now the cloned div is above the original; it hides the original) 
    702         this.map.viewPortDiv.appendChild(this.map.layerContainerDivClone); 
    703          
    704         this.map.layerContainerDiv.style.display= "none"; 
    705  
     693         
     694        // function for map only; not for overviewmap! 
     695        if (this.map.div.id == "map") {   
     696            // 1. clone layerContainerDiv with all childs (replace, if already exist) 
     697            if (this.map.layerContainerDivClone){ 
     698                this.map.viewPortDiv.removeChild(this.map.layerContainerDivClone); 
     699                this.map.layerContainerDivClone = null; 
     700            } 
     701            this.map.layerContainerDivClone = this.map.layerContainerDiv.cloneNode(true); 
     702            this.map.layerContainerDivClone.id = "map_OpenLayers_Container_clone"; 
     703            // 2. append layerContainerDivClone to viewPortDiv 
     704            // (now the cloned div is above the original; it hides the original) 
     705            this.map.viewPortDiv.appendChild(this.map.layerContainerDivClone); 
     706             
     707            this.map.layerContainerDiv.style.display= "none"; 
     708        } 
    706709    }, 
    707710