Changeset 1296
- Timestamp:
- 08/17/06 16:27:41 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/openlayers/2.0/lib/OpenLayers/Layer/HTTPRequest.js
r1295 r1296 37 37 }, 38 38 39 /** When the layer is added to the map, once it has taken all the40 * relevant properties from the map (in Layer.setMap()), we will41 * make the call to initialize the layer's resolutions array.42 *43 * @param {OpenLayers.Map} map44 */45 39 setMap: function(map) { 46 40 OpenLayers.Layer.prototype.setMap.apply(this, arguments); 47 41 this.initResolutions(); 48 42 }, 49 50 43 /** 51 44 * … … 139 132 }, 140 133 141 /** @private142 *143 */144 134 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) { 156 141 this.maxZoomLevel = this.resolutions.length; 157 142 } else { 158 143 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); 166 146 var maxRes = this.getMaxResolution(); 167 168 147 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)); 173 152 } 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++) { 180 154 this.resolutions.push(maxRes / Math.pow(2, i)); 181 155 } … … 183 157 }, 184 158 185 /**186 * @returns The currently selected resolution of the map, taken from the187 * resolutions array, indexed by current zoom level.188 * @type float189 */190 159 getResolution: function() { 191 160 var zoom = this.map.getZoom(); branches/openlayers/2.0/lib/OpenLayers/Map.js
r1295 r1296 707 707 maxResolution = this.baseLayer.getMaxResolution(); 708 708 } 709 710 if (maxResolution == null) { 711 maxResolution = this.maxResolution; 712 } 713 709 714 return maxResolution; 710 715 },
