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:
@@ -375,9 +375,22 @@ OpenLayers.Layer.prototype = {
|
|||||||
var viewSize = this.map.getSize();
|
var viewSize = this.map.getSize();
|
||||||
var idealResolution = Math.max( extent.getWidth() / viewSize.w,
|
var idealResolution = Math.max( extent.getWidth() / viewSize.w,
|
||||||
extent.getHeight() / viewSize.h );
|
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++) {
|
for(var i=1; i <= this.resolutions.length; i++) {
|
||||||
if ( this.resolutions[i] < idealResolution) {
|
if ( this.resolutions[i] < resolution) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -781,12 +781,12 @@ OpenLayers.Map.prototype = {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {OpenLayers.Bounds} bounds
|
* @param {OpenLayers.Bounds} bounds
|
||||||
*
|
*
|
||||||
* @returns A suitable zoom level for the specified bounds.
|
* @returns A suitable zoom level for the specified bounds.
|
||||||
* If no baselayer is set, returns null.
|
* If no baselayer is set, returns null.
|
||||||
* @type int
|
* @type int
|
||||||
*/
|
*/
|
||||||
getZoomForExtent: function (bounds) {
|
getZoomForExtent: function (bounds) {
|
||||||
zoom = null;
|
zoom = null;
|
||||||
if (this.baseLayer != null) {
|
if (this.baseLayer != null) {
|
||||||
@@ -795,6 +795,21 @@ OpenLayers.Map.prototype = {
|
|||||||
return zoom;
|
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 */
|
/* Zooming Functions */
|
||||||
|
|||||||
Reference in New Issue
Block a user