OpenLayers OpenLayers

Changeset 1296

Show
Ignore:
Timestamp:
08/17/06 16:27:41 (2 years ago)
Author:
euzuro
Message:

rollback 1295 -- prematurely committed

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/openlayers/2.0/lib/OpenLayers/Layer/HTTPRequest.js

    r1295 r1296  
    3737    }, 
    3838 
    39     /** When the layer is added to the map, once it has taken all the  
    40      *   relevant properties from the map (in Layer.setMap()), we will 
    41      *   make the call to initialize the layer's resolutions array. 
    42      *  
    43      * @param {OpenLayers.Map} map 
    44      */ 
    4539    setMap: function(map) { 
    4640        OpenLayers.Layer.prototype.setMap.apply(this, arguments); 
    4741        this.initResolutions(); 
    4842    }, 
    49      
    5043    /** 
    5144     *  
     
    139132    }, 
    140133     
    141     /** @private 
    142      *  
    143      */ 
    144134    initResolutions: function() { 
    145          
    146         if ((this.scales != null) || (this.resolutions != null)) { 
    147             if (this.scales != null) { 
    148                 //convert the scales into resolutions.  
    149                 this.resolutions = new Array(); 
    150                 for(var i = 0; i < this.scales.length; i++) { 
    151                     this.resolutions[i] =  
    152                        OpenLayers.Util.getResolutionFromScale(this.scales[i],  
    153                                                               this.units); 
    154                 } 
    155             } 
     135        if (this.scales != null) { 
     136            this.resolutions = new Array(); 
     137            for(var i = 0; i < this.scales.length; i++)  
     138                this.resolutions[i] = OpenLayers.Util.getResolutionFromScale(this.scales[i], this.units); 
     139            this.maxZoomLevel = this.resolutions.length; 
     140        } else if (this.resolutions != null) { 
    156141            this.maxZoomLevel = this.resolutions.length; 
    157142        } else { 
    158143            this.resolutions = new Array(); 
    159  
    160             if (this.minScale) { 
    161                 this.maxResolution =  
    162                     OpenLayers.Util.getResolutionFromScale(this.minScale,  
    163                                                            this.units); 
    164             } 
    165  
     144            if (this.minScale) 
     145                this.maxResolution = OpenLayers.Util.getResolutionFromScale(this.minScale, this.units); 
    166146            var maxRes = this.getMaxResolution(); 
    167  
    168147            if (this.maxScale) { 
    169                 var minRes =  
    170                     OpenLayers.Util.getResolutionFromScale(this.maxScale); 
    171                 this.maxZoomLevel = Math.floor(Math.log(maxRes/minRes) /  
    172                                               Math.log(2)); 
     148                /* This will cause this.map.getMaxZoomLevel() to be set the next time 
     149                 * it is called, which means that the next portion here will succeed. */ 
     150                var minRes = OpenLayers.Util.getResolutionFromScale(this.maxScale); 
     151                this.maxZoomLevel = Math.floor(Math.log(maxRes/minRes) / Math.log(2)); 
    173152            }     
    174  
    175             //at this point, min and max zoom levels are correctly set, so  
    176             // iterate and add them to the resolutions array. 
    177             var minZoomLevel = this.getMinZoomLevel()  
    178             var maxZoomLevel = this.getMaxZoomLevel()  
    179             for (var i = minZoomLevel; i <= maxZoomLevel; i++) { 
     153            for (var i=this.getMinZoomLevel(); i <= this.getMaxZoomLevel(); i++) { 
    180154                this.resolutions.push(maxRes / Math.pow(2, i)); 
    181155            }     
     
    183157    }, 
    184158     
    185     /** 
    186      * @returns The currently selected resolution of the map, taken from the 
    187      *          resolutions array, indexed by current zoom level. 
    188      * @type float 
    189      */ 
    190159    getResolution: function() { 
    191160        var zoom = this.map.getZoom(); 
  • branches/openlayers/2.0/lib/OpenLayers/Map.js

    r1295 r1296  
    707707            maxResolution = this.baseLayer.getMaxResolution(); 
    708708        } 
     709 
     710        if (maxResolution == null) { 
     711            maxResolution = this.maxResolution; 
     712        } 
     713 
    709714        return maxResolution; 
    710715    },