OpenLayers OpenLayers

Ticket #967: 967.patch

File 967.patch, 2.8 kB (added by crschmidt, 10 months ago)

use caller instead of source

  • 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  
    12591259     * 
    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            'caller': '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(); 
    12671291        } 
     
    13111335        // if neither center nor zoom will change, no need to do anything 
    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) { 
    13171343                if ((!zoomChanged) && (this.center)) {  
     
    13771403        } 
    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 
    13831411    /**