Renamed option to constrainOneAxis

This commit is contained in:
Jeremy Smith
2020-01-30 07:40:28 +10:00
parent 4151e86c0a
commit 7805768942
2 changed files with 21 additions and 20 deletions

View File

@@ -129,8 +129,9 @@ import {createMinMaxResolution} from './resolutionconstraint.js';
* @property {boolean} [smoothResolutionConstraint=true] If true, the resolution
* min/max values will be applied smoothly, i. e. allow the view to exceed slightly
* the given resolution or zoom bounds.
* @property {boolean} [largerResolutionConstraint=false] If true, the constrained
* resolution values will use the larger value to do so.
* @property {boolean} [constrainOneAxis=false] If true, the extent constraint can
* be exceeded along one but not both axes, allowing the whole extent to be visible
* on the map.
* @property {import("./proj.js").ProjectionLike} [projection='EPSG:3857'] The
* projection. The default is Spherical Mercator.
* @property {number} [resolution] The initial resolution for the view. The
@@ -1613,8 +1614,8 @@ export function createResolutionConstraint(options) {
const smooth =
options.smoothResolutionConstraint !== undefined ? options.smoothResolutionConstraint : true;
const larger =
options.largerResolutionConstraint !== undefined ? options.largerResolutionConstraint : false;
const oneAxis =
options.constrainOneAxis !== undefined ? options.constrainOneAxis : false;
const projection = createProjection(options.projection, 'EPSG:3857');
const projExtent = projection.getExtent();
@@ -1633,10 +1634,10 @@ export function createResolutionConstraint(options) {
if (options.constrainResolution) {
resolutionConstraint = createSnapToResolutions(resolutions, smooth,
!constrainOnlyCenter && extent, larger);
!constrainOnlyCenter && extent, oneAxis);
} else {
resolutionConstraint = createMinMaxResolution(maxResolution, minResolution, smooth,
!constrainOnlyCenter && extent, larger);
!constrainOnlyCenter && extent, oneAxis);
}
} else {
// calculate the default min and max resolution
@@ -1682,10 +1683,10 @@ export function createResolutionConstraint(options) {
if (options.constrainResolution) {
resolutionConstraint = createSnapToPower(
zoomFactor, maxResolution, minResolution, smooth,
!constrainOnlyCenter && extent, larger);
!constrainOnlyCenter && extent, oneAxis);
} else {
resolutionConstraint = createMinMaxResolution(maxResolution, minResolution, smooth,
!constrainOnlyCenter && extent, larger);
!constrainOnlyCenter && extent, oneAxis);
}
}
return {constraint: resolutionConstraint, maxResolution: maxResolution,