OpenLayers OpenLayers

Changeset 1295

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

coding standards, adding jsdoc comments, small code reorganization in svn statavkn

Files:

Legend:

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

    r1228 r1295  
    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     */ 
    3945    setMap: function(map) { 
    4046        OpenLayers.Layer.prototype.setMap.apply(this, arguments); 
    4147        this.initResolutions(); 
    4248    }, 
     49     
    4350    /** 
    4451     *  
     
    132139    }, 
    133140     
     141    /** @private 
     142     *  
     143     */ 
    134144    initResolutions: function() { 
    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) { 
     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            } 
    141156            this.maxZoomLevel = this.resolutions.length; 
    142157        } else { 
    143158            this.resolutions = new Array(); 
    144             if (this.minScale) 
    145                 this.maxResolution = OpenLayers.Util.getResolutionFromScale(this.minScale, this.units); 
     159 
     160            if (this.minScale) { 
     161                this.maxResolution =  
     162                    OpenLayers.Util.getResolutionFromScale(this.minScale,  
     163                                                           this.units); 
     164            } 
     165 
    146166            var maxRes = this.getMaxResolution(); 
     167 
    147168            if (this.maxScale) { 
    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)); 
     169                var minRes =  
     170                    OpenLayers.Util.getResolutionFromScale(this.maxScale); 
     171                this.maxZoomLevel = Math.floor(Math.log(maxRes/minRes) /  
     172                                              Math.log(2)); 
    152173            }     
    153             for (var i=this.getMinZoomLevel(); i <= this.getMaxZoomLevel(); i++) { 
     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++) { 
    154180                this.resolutions.push(maxRes / Math.pow(2, i)); 
    155181            }     
     
    157183    }, 
    158184     
     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     */ 
    159190    getResolution: function() { 
    160191        var zoom = this.map.getZoom(); 
  • branches/openlayers/2.0/lib/OpenLayers/Map.js

    r1283 r1295  
    707707            maxResolution = this.baseLayer.getMaxResolution(); 
    708708        } 
    709  
    710         if (maxResolution == null) { 
    711             maxResolution = this.maxResolution; 
    712         } 
    713  
    714709        return maxResolution; 
    715710    },