OpenLayers OpenLayers

Changeset 6045

Show
Ignore:
Timestamp:
02/07/08 16:59:03 (1 year ago)
Author:
crschmidt
Message:

Add version of animated panning:

  • With cancel-on-drag support
  • With pan as a wrapper for panTo
  • With a more fun example (dancing map!)

Depends on current patches for #967 and on #1308

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/crschmidt/animated_panning/lib/OpenLayers/Control/OverviewMap.js

    r6010 r6045  
    435435        // create the overview map 
    436436        var options = OpenLayers.Util.extend( 
    437                         {controls: [], maxResolution: 'auto'}, this.mapOptions); 
     437                        {controls: [], maxResolution: 'auto', 'fallThrough': false}, this.mapOptions); 
    438438        this.ovmap = new OpenLayers.Map(this.mapDiv, options); 
    439439         
     
    511511    updateMapToRect: function() { 
    512512        var lonLatBounds = this.getMapBoundsFromRectBounds(this.rectPxBounds); 
    513         this.map.setCenter(lonLatBounds.getCenterLonLat(), this.map.zoom); 
     513        this.map.panTo(lonLatBounds.getCenterLonLat()); 
    514514    }, 
    515515 
  • sandbox/crschmidt/animated_panning/lib/OpenLayers/Map.js

    r6035 r6045  
    12421242        if (!newCenterPx.equals(centerPx)) { 
    12431243            var newCenterLonLat = this.getLonLatFromViewPortPx(newCenterPx); 
    1244             this.setCenter(newCenterLonLat); 
     1244            this.panTo(newCenterLonLat); 
    12451245        } 
    12461246 
    12471247   }, 
     1248    
     1249   /**  
     1250     * APIMethod: panTo 
     1251     * Allows user to pan to a new lonlat 
     1252     * If the new lonlat is in the current extent the map will slide smoothly 
     1253     *  
     1254     * Parameters: 
     1255     * lonlat - {<OpenLayers.Lonlat>} 
     1256     */ 
     1257    panTo: function(lonlat) { 
     1258        if (this.getExtent().containsLonLat(lonlat)) { 
     1259            if (!this.panTween) { 
     1260                this.panTween = new OpenLayers.Tween(OpenLayers.Easing.Expo.easeOut); 
     1261            } 
     1262            var center = this.getCenter(); 
     1263            var from = { 
     1264                lon: center.lon, 
     1265                lat: center.lat 
     1266            }; 
     1267            var to = { 
     1268                lon: lonlat.lon, 
     1269                lat: lonlat.lat 
     1270            }; 
     1271            this.panTween.start(from, to, 50, { 
     1272                callbacks: { 
     1273                    start: OpenLayers.Function.bind(function(lonlat) { 
     1274                        this.events.triggerEvent("movestart"); 
     1275                    }, this), 
     1276                    eachStep: OpenLayers.Function.bind(function(lonlat) { 
     1277                        var lonlat = new OpenLayers.LonLat(lonlat.lon, lonlat.lat); 
     1278                        this.moveTo(lonlat, this.zoom, true); 
     1279                    }, this), 
     1280                    done: OpenLayers.Function.bind(function(lonlat) { 
     1281                        this.events.triggerEvent("moveend"); 
     1282                    }, this) 
     1283                } 
     1284            }); 
     1285        } else { 
     1286            this.setCenter(lonlat); 
     1287        } 
     1288    }, 
    12481289 
    12491290    /** 
     
    12861327        // noEvent is false by default 
    12871328        var noEvent = options.noEvent; 
     1329 
     1330        if (this.panTween && options.source == "setCenter") { 
     1331            this.panTween.stop(); 
     1332        }     
    12881333              
    12891334        if (!this.center && !this.isValidLonLat(lonlat)) {