Fix DragZoom with View padding
This commit is contained in:
@@ -5,11 +5,11 @@ import DragBox from './DragBox.js';
|
|||||||
import {
|
import {
|
||||||
createOrUpdateFromCoordinates,
|
createOrUpdateFromCoordinates,
|
||||||
getBottomLeft,
|
getBottomLeft,
|
||||||
getCenter,
|
|
||||||
getTopRight,
|
getTopRight,
|
||||||
scaleFromCenter,
|
scaleFromCenter,
|
||||||
} from '../extent.js';
|
} from '../extent.js';
|
||||||
import {easeOut} from '../easing.js';
|
import {easeOut} from '../easing.js';
|
||||||
|
import {fromExtent as polygonFromExtent} from '../geom/Polygon.js';
|
||||||
import {shiftKeyOnly} from '../events/condition.js';
|
import {shiftKeyOnly} from '../events/condition.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,10 +71,10 @@ class DragZoom extends DragBox {
|
|||||||
onBoxEnd(event) {
|
onBoxEnd(event) {
|
||||||
const map = this.getMap();
|
const map = this.getMap();
|
||||||
const view = /** @type {!import("../View.js").default} */ (map.getView());
|
const view = /** @type {!import("../View.js").default} */ (map.getView());
|
||||||
const size = /** @type {!import("../size.js").Size} */ (map.getSize());
|
|
||||||
let extent = this.getGeometry().getExtent();
|
let extent = this.getGeometry().getExtent();
|
||||||
|
|
||||||
if (this.out_) {
|
if (this.out_) {
|
||||||
|
const size = /** @type {!import("../size.js").Size} */ (map.getSize());
|
||||||
const mapExtent = view.calculateExtentInternal(size);
|
const mapExtent = view.calculateExtentInternal(size);
|
||||||
const boxPixelExtent = createOrUpdateFromCoordinates([
|
const boxPixelExtent = createOrUpdateFromCoordinates([
|
||||||
map.getPixelFromCoordinateInternal(getBottomLeft(extent)),
|
map.getPixelFromCoordinateInternal(getBottomLeft(extent)),
|
||||||
@@ -86,14 +86,7 @@ class DragZoom extends DragBox {
|
|||||||
extent = mapExtent;
|
extent = mapExtent;
|
||||||
}
|
}
|
||||||
|
|
||||||
const resolution = view.getConstrainedResolution(
|
view.fitInternal(polygonFromExtent(extent), {
|
||||||
view.getResolutionForExtentInternal(extent, size)
|
|
||||||
);
|
|
||||||
const center = view.getConstrainedCenter(getCenter(extent), resolution);
|
|
||||||
|
|
||||||
view.animateInternal({
|
|
||||||
resolution: resolution,
|
|
||||||
center: center,
|
|
||||||
duration: this.duration_,
|
duration: this.duration_,
|
||||||
easing: easeOut,
|
easing: easeOut,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user