Show only one world

This commit is contained in:
ahocevar
2019-03-22 21:55:54 +01:00
parent a95481a8fe
commit 3940b5ec88
6 changed files with 97 additions and 46 deletions

View File

@@ -120,6 +120,7 @@ import {createMinMaxResolution} from './resolutionconstraint';
* resolution constraint. It is used together with `maxZoom` (or
* `minResolution`) and `zoomFactor`. Note that if `maxResolution` is also
* provided, it is given precedence over `minZoom`.
* @property {boolean} [multiWorld=false] No more than one world is visible.
* @property {boolean} [constrainResolution=false] If true, the view will always
* animate to the closest zoom level after an interaction; false means
* intermediary zoom levels are allowed.
@@ -1435,6 +1436,9 @@ export function createResolutionConstraint(options) {
const zoomFactor = options.zoomFactor !== undefined ?
options.zoomFactor : defaultZoomFactor;
const multiWorld = options.multiWorld !== undefined ?
options.multiWorld : false;
const smooth =
options.smoothResolutionConstraint !== undefined ? options.smoothResolutionConstraint : true;
@@ -1499,8 +1503,14 @@ export function createResolutionConstraint(options) {
zoomFactor, maxResolution, minResolution, smooth,
!options.constrainOnlyCenter && options.extent);
} else {
let constrainOnlyCenter = options.constrainOnlyCenter;
let extent = options.extent;
if (!multiWorld && !extent && projection.isGlobal()) {
constrainOnlyCenter = false;
extent = projection.getExtent();
}
resolutionConstraint = createMinMaxResolution(maxResolution, minResolution, smooth,
!options.constrainOnlyCenter && options.extent);
!constrainOnlyCenter && extent);
}
}
return {constraint: resolutionConstraint, maxResolution: maxResolution,