Merge pull request #6966 from ahocevar/resolution-for-zoom
Add getResolutionForZoom method for ol.View
This commit is contained in:
@@ -809,6 +809,18 @@ ol.View.prototype.getZoomForResolution = function(resolution) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the resolution for a zoom level.
|
||||
* @param {number} zoom Zoom level.
|
||||
* @return {number} The view resolution for the provided zoom level.
|
||||
* @api
|
||||
*/
|
||||
ol.View.prototype.getResolutionForZoom = function(zoom) {
|
||||
return /** @type {number} */ (this.constrainResolution(
|
||||
this.maxResolution_, zoom - this.minZoom_, 0));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Fit the given geometry or extent based on the given map size and border.
|
||||
* The size is pixel dimensions of the box to fit the extent into.
|
||||
@@ -1025,9 +1037,7 @@ ol.View.prototype.setRotation = function(rotation) {
|
||||
* @api
|
||||
*/
|
||||
ol.View.prototype.setZoom = function(zoom) {
|
||||
var resolution = this.constrainResolution(
|
||||
this.maxResolution_, zoom - this.minZoom_, 0);
|
||||
this.setResolution(resolution);
|
||||
this.setResolution(this.getResolutionForZoom(zoom));
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user