OpenLayers OpenLayers

Changeset 6035

Show
Ignore:
Timestamp:
02/07/08 16:42:11 (10 months ago)
Author:
crschmidt
Message:

Minor modifications to the map.setCenter / map.moveTo rewrite. (See #962)

Files:

Legend:

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

    r5982 r6035  
    12601260     * TBD: reconsider forceZoomChange in 3.0 
    12611261     */ 
    1262     setCenter: function (lonlat, zoom, dragging, forceZoomChange) { 
    1263         this.dragging = !!dragging; 
    1264          
     1262    setCenter: function(lonlat, zoom, dragging, forceZoomChange) { 
     1263        this.moveTo(lonlat, zoom, { 
     1264            'dragging': dragging, 
     1265            'forceZoomChange': forceZoomChange, 
     1266            'source': 'setCenter' 
     1267        }); 
     1268    }, 
     1269 
     1270    /** 
     1271     * Method: moveTo 
     1272     * 
     1273     * Parameters: 
     1274     * lonlat - {<OpenLayers.LonLat>} 
     1275     * zoom - {Integer} 
     1276     * options - {Object} 
     1277     */ 
     1278    moveTo: function(lonlat, zoom, options) { 
     1279        if (!options) {  
     1280            options = {}; 
     1281        }     
     1282        // dragging is false by default 
     1283        var dragging = options.dragging; 
     1284        // forceZoomChange is false by default 
     1285        var forceZoomChange = options.forceZoomChange; 
     1286        // noEvent is false by default 
     1287        var noEvent = options.noEvent; 
     1288              
    12651289        if (!this.center && !this.isValidLonLat(lonlat)) { 
    12661290            lonlat = this.maxExtent.getCenterLonLat(); 
     
    13121336        if (zoomChanged || centerChanged || !dragging) { 
    13131337 
    1314             if (!dragging) { this.events.triggerEvent("movestart"); } 
     1338            if (!dragging && !noEvent) { 
     1339                this.events.triggerEvent("movestart"); 
     1340            } 
    13151341 
    13161342            if (centerChanged) { 
     
    13781404 
    13791405        // even if nothing was done, we want to notify of this 
    1380         if (!dragging) { this.events.triggerEvent("moveend"); } 
     1406        if (!dragging && !noEvent) { 
     1407            this.events.triggerEvent("moveend"); 
     1408        } 
    13811409    }, 
    13821410 
  • sandbox/crschmidt/animated_panning/tests/test_Map.html

    r5982 r6035  
    727727    } 
    728728 
    729     function test_15_Map_setCenter(t) { 
     729    function test_15_Map_moveTo(t) { 
    730730        t.plan(1); 
    731731 
     
    737737        map.addLayer(baseLayer); 
    738738        var ll = new OpenLayers.LonLat(-100,-150); 
    739         map.setCenter(ll, 0); 
     739        map.moveTo(ll, 0); 
    740740        t.ok(map.getCenter().equals(new OpenLayers.LonLat(0,0)), "safely sets out-of-bounds lonlat"); 
    741741    }