OpenLayers OpenLayers

Changeset 5540

Show
Ignore:
Timestamp:
12/20/07 12:42:21 (1 year ago)
Author:
enjahova
Message:

fixed map.js to have zoomToLastExtent again

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/enjahova/openlayers/lib/OpenLayers/Map.js

    r5518 r5540  
    136136    viewRequestID: 0, 
    137137 
     138    /** 
     139     * Property extents 
     140     * {Array} Used to store a history of the extents 
     141     */ 
     142    extents: [], 
     143 
    138144  // Options 
    139145 
     
    377383        // always call map.destroy() 
    378384        OpenLayers.Event.observe(window, 'unload', this.unloadDestroy); 
    379  
     385         
     386        //keep track of previous extents so we can "undo" them Used by ZoomToLastExtent 
     387        var func = function () {  
     388            //console.log(this.getExtent()); 
     389            //console.log(this.getScale()); 
     390            this.extents.push(this.getExtent()); 
     391        } 
     392        this.events.register("moveend", map, func ); 
    380393    }, 
    381394 
     
    16691682    }, 
    16701683 
     1684    /**  
     1685     * APIMethod: zoomToLastExtent 
     1686     * Zoom to the full extent and recenter. 
     1687     */ 
     1688    zoomToLastExtent: function() { 
     1689        //maybe not the cleanest way to do this (no 'redo') but it works 
     1690        if(this.extents.length > 1) 
     1691        { 
     1692            var tmp = this.extents.pop(); 
     1693            var last_extent = this.extents.pop(); 
     1694            this.zoomToExtent(last_extent); 
     1695        } 
     1696        else 
     1697        { 
     1698            this.zoomToMaxExtent(); 
     1699            this.extents.pop();this.extents.pop();//original extent should leave extents empty 
     1700        } 
     1701    }, 
     1702 
    16711703    /**  
    16721704     * APIMethod: zoomToScale