UI: Fix image map resize. Improve image input widgets to show/hide control buttons.

This commit is contained in:
Igor Kulikov 2022-01-27 13:11:52 +02:00
parent e8eb7083b3
commit 70c152ad92
2 changed files with 15 additions and 11 deletions

File diff suppressed because one or more lines are too long

View File

@ -164,6 +164,7 @@ export class ImageMap extends LeafletMap {
const southWest = this.pointToLatLng(-padding, h + padding); const southWest = this.pointToLatLng(-padding, h + padding);
const northEast = this.pointToLatLng(w + padding, -padding); const northEast = this.pointToLatLng(w + padding, -padding);
const maxBounds = new L.LatLngBounds(southWest, northEast); const maxBounds = new L.LatLngBounds(southWest, northEast);
(this.map as any)._enforcingBounds = true;
this.map.setMaxBounds(maxBounds); this.map.setMaxBounds(maxBounds);
if (lastCenterPos) { if (lastCenterPos) {
lastCenterPos.x *= w; lastCenterPos.x *= w;
@ -171,6 +172,7 @@ export class ImageMap extends LeafletMap {
const center = this.pointToLatLng(lastCenterPos.x, lastCenterPos.y); const center = this.pointToLatLng(lastCenterPos.x, lastCenterPos.y);
this.map.panTo(center, { animate: false }); this.map.panTo(center, { animate: false });
} }
(this.map as any)._enforcingBounds = false;
} }
onResize(updateImage?: boolean) { onResize(updateImage?: boolean) {
@ -195,7 +197,9 @@ export class ImageMap extends LeafletMap {
lastCenterPos.x /= prevWidth; lastCenterPos.x /= prevWidth;
lastCenterPos.y /= prevHeight; lastCenterPos.y /= prevHeight;
this.updateBounds(updateImage, lastCenterPos); this.updateBounds(updateImage, lastCenterPos);
this.map.invalidateSize(true); (this.map as any)._enforcingBounds = true;
this.map.invalidateSize(false);
(this.map as any)._enforcingBounds = false;
this.updateMarkers(this.markersData); this.updateMarkers(this.markersData);
if (this.options.draggableMarker && this.addMarkers.length) { if (this.options.draggableMarker && this.addMarkers.length) {
this.addMarkers.forEach((marker) => { this.addMarkers.forEach((marker) => {
@ -266,7 +270,7 @@ export class ImageMap extends LeafletMap {
return L.CRS.Simple.pointToLatLng({ x, y } as L.PointExpression, maxZoom - 1); return L.CRS.Simple.pointToLatLng({ x, y } as L.PointExpression, maxZoom - 1);
} }
latLngToPoint(latLng: LatLngLiteral) { latLngToPoint(latLng: LatLngLiteral): L.Point {
return L.CRS.Simple.latLngToPoint(latLng, maxZoom - 1); return L.CRS.Simple.latLngToPoint(latLng, maxZoom - 1);
} }