Move getZoomForExtent from WMS to Grid. This also applies to WorldWind and KaMap, so having it in Grid.js means we can use it in more cases where it will matter.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@820 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -89,49 +89,6 @@ OpenLayers.Layer.WMS.prototype =
|
||||
url, this.tileSize);
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @returns Degrees per Pixel
|
||||
* @type float
|
||||
*/
|
||||
getResolution: function() {
|
||||
var maxRes = this.map.getMaxResolution();
|
||||
var zoom = this.map.getZoom();
|
||||
|
||||
return maxRes / Math.pow(2, zoom);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
*
|
||||
* @return {int}
|
||||
*/
|
||||
getZoomForExtent: function (bounds) {
|
||||
|
||||
var maxRes = this.map.getMaxResolution();
|
||||
var viewSize = this.map.getSize();
|
||||
|
||||
var width = bounds.getWidth();
|
||||
var height = bounds.getHeight();
|
||||
|
||||
var degPerPixel = (width > height) ? width / viewSize.w
|
||||
: height / viewSize.h;
|
||||
|
||||
var zoom = Math.floor( (Math.log(maxRes/degPerPixel)) / Math.log(2) );
|
||||
|
||||
var maxZoomLevel = this.map.getMaxZoomLevel();
|
||||
var minZoomLevel = this.map.getMinZoomLevel();
|
||||
|
||||
//make sure zoom is within bounds
|
||||
zoom = Math.min( Math.max(zoom, minZoomLevel),
|
||||
maxZoomLevel );
|
||||
|
||||
return zoom;
|
||||
},
|
||||
|
||||
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Layer.WMS"
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user