Merge pull request #5876 from vvlladd28/improvement/map/image-map-resize
[3.3.3] UI: Improvement image map resize - correct calculate center position
This commit is contained in:
commit
ba0d42d538
@ -300,8 +300,8 @@ export class MapWidgetController implements MapWidgetInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resize() {
|
resize() {
|
||||||
this.map?.invalidateSize();
|
this.map.onResize();
|
||||||
this.map.onResize();
|
this.map?.invalidateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
|
|||||||
@ -159,27 +159,25 @@ export class ImageMap extends LeafletMap {
|
|||||||
lastCenterPos.x *= w;
|
lastCenterPos.x *= w;
|
||||||
lastCenterPos.y *= h;
|
lastCenterPos.y *= h;
|
||||||
const center = this.pointToLatLng(lastCenterPos.x, lastCenterPos.y);
|
const center = this.pointToLatLng(lastCenterPos.x, lastCenterPos.y);
|
||||||
setTimeout(() => {
|
this.map.panTo(center, { animate: false });
|
||||||
this.map.panTo(center, { animate: false });
|
|
||||||
}, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onResize(updateImage?: boolean) {
|
onResize(updateImage?: boolean) {
|
||||||
let width = this.$container.clientWidth;
|
let width = this.$container.clientWidth;
|
||||||
if (width > 0 && this.aspect) {
|
if (width > 0 && this.aspect) {
|
||||||
let height = width / this.aspect;
|
let height = Math.round(width / this.aspect);
|
||||||
const imageMapHeight = this.$container.clientHeight;
|
const imageMapHeight = this.$container.clientHeight;
|
||||||
if (imageMapHeight > 0 && height > imageMapHeight) {
|
if (imageMapHeight > 0 && height > imageMapHeight) {
|
||||||
height = imageMapHeight;
|
height = imageMapHeight;
|
||||||
width = height * this.aspect;
|
width = Math.round(height * this.aspect);
|
||||||
}
|
}
|
||||||
width *= maxZoom;
|
width *= maxZoom;
|
||||||
const prevWidth = this.width;
|
const prevWidth = this.width;
|
||||||
const prevHeight = this.height;
|
const prevHeight = this.height;
|
||||||
if (this.width !== width || updateImage) {
|
if (this.width !== width || updateImage) {
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = width / this.aspect;
|
this.height = Math.round(width / this.aspect);
|
||||||
if (!this.map) {
|
if (!this.map) {
|
||||||
this.initMap(updateImage);
|
this.initMap(updateImage);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user