added getZoomForResolution() to map & layer. partial fix for #204 -- need to make a getZoomForResolution() for OpenLayers.Layer.FixedZoomLevels
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1382 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -376,8 +376,21 @@ OpenLayers.Layer.prototype = {
|
||||
var idealResolution = Math.max( extent.getWidth() / viewSize.w,
|
||||
extent.getHeight() / viewSize.h );
|
||||
|
||||
return this.getZoomForResolution(idealResolution);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {float} resolution
|
||||
*
|
||||
* @returns The index of the zoomLevel (entry in the resolutions array)
|
||||
* that is the smallest resolution that is greater than the
|
||||
* passed-in resolution.
|
||||
* @type int
|
||||
*/
|
||||
getZoomForResolution: function(resolution) {
|
||||
|
||||
for(var i=1; i <= this.resolutions.length; i++) {
|
||||
if ( this.resolutions[i] < idealResolution) {
|
||||
if ( this.resolutions[i] < resolution) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -781,12 +781,12 @@ OpenLayers.Map.prototype = {
|
||||
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
*
|
||||
* @returns A suitable zoom level for the specified bounds.
|
||||
* If no baselayer is set, returns null.
|
||||
* @type int
|
||||
*/
|
||||
* @param {OpenLayers.Bounds} bounds
|
||||
*
|
||||
* @returns A suitable zoom level for the specified bounds.
|
||||
* If no baselayer is set, returns null.
|
||||
* @type int
|
||||
*/
|
||||
getZoomForExtent: function (bounds) {
|
||||
zoom = null;
|
||||
if (this.baseLayer != null) {
|
||||
@@ -795,6 +795,21 @@ OpenLayers.Map.prototype = {
|
||||
return zoom;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {float} resolution
|
||||
*
|
||||
* @returns A suitable zoom level for the specified resolution.
|
||||
* If no baselayer is set, returns null.
|
||||
* @type int
|
||||
*/
|
||||
getZoomForResolution: function(resolution) {
|
||||
zoom = null;
|
||||
if (this.baseLayer != null) {
|
||||
zoom = this.baseLayer.getZoomForResolution(resolution);
|
||||
}
|
||||
return zoom;
|
||||
},
|
||||
|
||||
/********************************************************/
|
||||
/* */
|
||||
/* Zooming Functions */
|
||||
|
||||
Reference in New Issue
Block a user