OpenLayers OpenLayers

Changeset 1537

Show
Ignore:
Timestamp:
10/03/06 00:34:51 (2 years ago)
Author:
crschmidt
Message:

Permalink will now save state if there's no base layer when it's added, and
change the map when the first baselayer loads.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Control/Permalink.js

    r1424 r1537  
    3737        var args = OpenLayers.Util.getArgs(); 
    3838        if (args.lat && args.lon) { 
    39             this.map.setCenter( 
    40                new OpenLayers.LonLat(parseFloat(args.lon), parseFloat(args.lat)) 
    41             ); 
     39            if (this.map.baseLayer) {  
     40                this.map.setCenter( 
     41                   new OpenLayers.LonLat(parseFloat(args.lon), parseFloat(args.lat)) 
     42                ); 
     43            } else { 
     44                this.centerData = new OpenLayers.LonLat( 
     45                                      parseFloat(args.lon), 
     46                                      parseFloat(args.lat)); 
     47                this.map.events.register( 'changebaselayer', this, this.setCenter); 
     48            } 
    4249        } 
    4350        if (args.zoom) { 
    44             this.map.zoomTo(parseInt(args.zoom)); 
     51            if (this.map.baseLayer) {  
     52                this.map.zoomTo(parseInt(args.zoom)); 
     53            } else { 
     54                this.zoomData = parseInt(args.zoom); 
     55            } 
    4556        } 
    4657        if (!this.element) { 
     
    7182        this.element.href = this.base+"?lat="+lat+"&lon="+lon+"&zoom="+zoom;  
    7283    },  
     84 
     85    setCenter: function() { 
     86        if (this.map.baseLayer && this.centerData) {  
     87            this.map.setCenter(this.centerData, this.zoomData ? this.zoomData : null); 
     88            this.centerData = null; 
     89        } 
     90    }, 
     91             
     92         
    7393     
    7494    /** @final @type String */