Changeset 1295
- Timestamp:
- 08/17/06 16:22:47 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/openlayers/2.0/lib/OpenLayers/Layer/HTTPRequest.js
r1228 r1295 37 37 }, 38 38 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 */ 39 45 setMap: function(map) { 40 46 OpenLayers.Layer.prototype.setMap.apply(this, arguments); 41 47 this.initResolutions(); 42 48 }, 49 43 50 /** 44 51 * … … 132 139 }, 133 140 141 /** @private 142 * 143 */ 134 144 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 } 141 156 this.maxZoomLevel = this.resolutions.length; 142 157 } else { 143 158 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 146 166 var maxRes = this.getMaxResolution(); 167 147 168 if (this.maxScale) { 148 /* This will cause this.map.getMaxZoomLevel() to be set the next time149 * 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)); 152 173 } 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++) { 154 180 this.resolutions.push(maxRes / Math.pow(2, i)); 155 181 } … … 157 183 }, 158 184 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 */ 159 190 getResolution: function() { 160 191 var zoom = this.map.getZoom(); branches/openlayers/2.0/lib/OpenLayers/Map.js
r1283 r1295 707 707 maxResolution = this.baseLayer.getMaxResolution(); 708 708 } 709 710 if (maxResolution == null) {711 maxResolution = this.maxResolution;712 }713 714 709 return maxResolution; 715 710 },
