Browse Source

UI: Map widgets - Fixed autozoom in edit mode.

pull/6090/head
Igor Kulikov 5 years ago
parent
commit
9cf12cbdfb
  1. 8
      ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts
  2. 3
      ui-ngx/src/app/modules/home/components/widget/lib/maps/polygon.ts

8
ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts

@ -355,6 +355,7 @@ export default abstract class LeafletMap {
this.ignoreUpdateBounds = true;
}
this.map.on('pm:globaldrawmodetoggled', (e) => this.ignoreUpdateBounds = e.enabled);
this.map.on('pm:globaleditmodetoggled', (e) => this.ignoreUpdateBounds = e.enabled);
this.map.on('pm:globaldragmodetoggled', (e) => this.ignoreUpdateBounds = e.enabled);
this.map.on('pm:globalremovalmodetoggled', (e) => this.ignoreUpdateBounds = e.enabled);
@ -754,9 +755,6 @@ export default abstract class LeafletMap {
}
private updateBoundsInternal() {
if (this.ignoreUpdateBounds) {
return;
}
const bounds = new L.LatLngBounds(null, null);
if (this.drawRoutes) {
this.polylines.forEach((polyline) => {
@ -785,7 +783,9 @@ export default abstract class LeafletMap {
if (bounds.isValid() && (!this.bounds || !this.bounds.isValid() || !this.bounds.equals(bounds)
&& this.options.fitMapBounds ? !mapBounds.contains(bounds) : false)) {
this.bounds = bounds;
this.fitBounds(bounds);
if (!this.ignoreUpdateBounds) {
this.fitBounds(bounds);
}
}
}

3
ui-ngx/src/app/modules/home/components/widget/lib/maps/polygon.ts

@ -70,6 +70,9 @@ export class Polygon {
// Change position (call in drag drop mode)
this.leafletPoly.on('pm:dragstart', () => this.editing = true);
this.leafletPoly.on('pm:dragend', () => this.editing = false);
// Rotate (call in rotate mode)
this.leafletPoly.on('pm:rotatestart', () => this.editing = true);
this.leafletPoly.on('pm:rotateend', () => this.editing = false);
// Change size/point (call in edit mode)
this.leafletPoly.on('pm:markerdragstart', () => this.editing = true);
this.leafletPoly.on('pm:markerdragend', () => this.editing = false);

Loading…
Cancel
Save