OpenLayers OpenLayers

Ticket #967: patch-967-r5950-B1.diff

File patch-967-r5950-B1.diff, 3.0 kB (added by pgiraud, 10 months ago)
  • tests/test_Map.html

    old new  
    726726        t.eq( ct, 3, "raiseLayer triggered changelayer the right # of times" ); 
    727727    } 
    728728 
    729     function test_15_Map_setCenter(t) { 
     729    function test_15_Map_moveTo(t) { 
    730730        t.plan(1); 
    731731 
    732732        map = new OpenLayers.Map('map'); 
     
    736736            {maxResolution: 'auto', maxExtent: new OpenLayers.Bounds(-10,-10,10,10)}); 
    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    } 
    742742 
  • lib/OpenLayers/Map.js

    old new  
    12511251     * 
    12521252     * TBD: reconsider forceZoomChange in 3.0 
    12531253     */ 
    1254     setCenter: function (lonlat, zoom, dragging, forceZoomChange) { 
    1255         this.dragging = !!dragging; 
    1256          
     1254    setCenter: function(lonlat, zoom, dragging, forceZoomChange) { 
     1255        this.moveTo(lonlat, zoom, { 
     1256            'dragging': dragging, 
     1257            'forceZoomChange': forceZoomChange 
     1258        }); 
     1259    }, 
     1260 
     1261    /** 
     1262     * Method: moveTo 
     1263     * 
     1264     * Parameters: 
     1265     * lonlat - {<OpenLayers.LonLat>} 
     1266     * zoom - {Integer} 
     1267     * options - {Object} 
     1268     */ 
     1269    moveTo: function(lonlat, zoom, options) { 
     1270        // dragging is false by default 
     1271        var dragging = (options && options.dragging); 
     1272        // forceZoomChange is false by default 
     1273        var forceZoomChange = (options && options.forceZoomChange); 
     1274        // noEvent is false by default 
     1275        var noEvent = (options && options.noEvent); 
     1276        // stopPanTween is true by default 
     1277        var stopPanTween = (!options || 
     1278                           options.stopPanTween == null || 
     1279                           options.stopPanTween); 
     1280                            
     1281        if (this.panTween && stopPanTween === true) { 
     1282            this.panTween.stop(); 
     1283        } 
     1284              
    12571285        if (!this.center && !this.isValidLonLat(lonlat)) { 
    12581286            lonlat = this.maxExtent.getCenterLonLat(); 
    12591287        } 
     
    13061334        // if neither center nor zoom will change, no need to do anything 
    13071335        if (zoomChanged || centerChanged || !dragging) { 
    13081336 
    1309             if (!dragging) { this.events.triggerEvent("movestart"); } 
     1337            if (!dragging && !noEvent) { 
     1338                this.events.triggerEvent("movestart"); 
     1339            } 
    13101340 
    13111341            if (centerChanged) { 
    13121342                if ((!zoomChanged) && (this.center)) {  
     
    13721402        } 
    13731403 
    13741404        // even if nothing was done, we want to notify of this 
    1375         if (!dragging) { this.events.triggerEvent("moveend"); } 
     1405        if (!dragging && !noEvent) { 
     1406            this.events.triggerEvent("moveend"); 
     1407        } 
    13761408    }, 
    13771409 
    13781410    /**