Add view.getZoomForResolution()

This commit is contained in:
Tim Schaub
2017-02-19 17:01:48 -07:00
parent a10926ac74
commit 719fa6e004
2 changed files with 47 additions and 3 deletions

View File

@@ -659,8 +659,22 @@ ol.View.prototype.getState = function() {
ol.View.prototype.getZoom = function() {
var zoom;
var resolution = this.getResolution();
if (resolution !== undefined &&
resolution >= this.minResolution_ && resolution <= this.maxResolution_) {
if (resolution !== undefined) {
zoom = this.getZoomForResolution(resolution);
}
return zoom;
};
/**
* Get the zoom level for a resolution.
* @param {number} resolution The resolution.
* @return {number|undefined} The zoom level for the provided resolution.
* @api
*/
ol.View.prototype.getZoomForResolution = function(resolution) {
var zoom;
if (resolution >= this.minResolution_ && resolution <= this.maxResolution_) {
var offset = this.minZoom_ || 0;
var max, zoomFactor;
if (this.resolutions_) {