Add ol.control.ResolutionConstraint.createContinuous
This commit is contained in:
@@ -11,6 +11,26 @@ goog.require('ol.array');
|
|||||||
ol.control.ResolutionConstraintType;
|
ol.control.ResolutionConstraintType;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} power Power.
|
||||||
|
* @param {number} maxResolution Maximum resolution.
|
||||||
|
* @param {number=} opt_minResolution Minimum resolution.
|
||||||
|
* @return {ol.control.ResolutionConstraintType} Zoom function.
|
||||||
|
*/
|
||||||
|
ol.control.ResolutionConstraint.createContinuous =
|
||||||
|
function(power, maxResolution, opt_minResolution) {
|
||||||
|
var minResolution = opt_minResolution || 0;
|
||||||
|
return function(resolution, delta) {
|
||||||
|
if (goog.isDef(resolution)) {
|
||||||
|
resolution /= Math.pow(power, delta);
|
||||||
|
return goog.math.clamp(resolution, minResolution, maxResolution);
|
||||||
|
} else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Array.<number>} resolutions Resolutions.
|
* @param {Array.<number>} resolutions Resolutions.
|
||||||
* @return {ol.control.ResolutionConstraintType} Zoom function.
|
* @return {ol.control.ResolutionConstraintType} Zoom function.
|
||||||
|
|||||||
Reference in New Issue
Block a user