View / add a method to compute a valid zoom level

The `getValidZoomLevel` apply the current resolution constraint to return
a value that is guaranteed valid.

This is used for interactions & controls which need a target value to work:
the +/- buttons, the zoom clider, the dragbox zoom and the mouse wheel zoom.
This commit is contained in:
Olivier Guyot
2019-01-06 14:25:00 +01:00
parent 4e1ece16ed
commit 3c1e3779e2
7 changed files with 92 additions and 25 deletions
+3 -3
View File
@@ -80,14 +80,14 @@ function onBoxEnd() {
extent = mapExtent;
}
const resolution = view.constrainResolution(
view.getResolutionForExtent(extent, size));
const resolution = view.getResolutionForExtent(extent, size);
const zoom = view.getValidZoomLevel(view.getZoomForResolution(resolution));
let center = getCenter(extent);
center = view.constrainCenter(center);
view.animate({
resolution: resolution,
zoom: zoom,
center: center,
duration: this.duration_,
easing: easeOut