|
|
|
@ -133,6 +133,7 @@ export abstract class TbMap<S extends BaseMapSettings> { |
|
|
|
private currentEditButton: L.TB.ToolbarButton; |
|
|
|
|
|
|
|
private dragMode = true; |
|
|
|
private createMapItemActionId: string; |
|
|
|
|
|
|
|
private get isPlacingItem(): boolean { |
|
|
|
return !!this.currentEditButton; |
|
|
|
@ -685,9 +686,14 @@ export abstract class TbMap<S extends BaseMapSettings> { |
|
|
|
} |
|
|
|
|
|
|
|
private createItem(actionData: PlaceMapItemActionData, prepareDrawMode: () => void) { |
|
|
|
if (this.isPlacingItem) { |
|
|
|
const actionId = 'id' in actionData.action ? actionData.action.id : 'map-button'; |
|
|
|
if (this.createMapItemActionId === actionId) { |
|
|
|
this.finishCreatedItem(); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (isDefined(this.createMapItemActionId)) { |
|
|
|
this.finishCreatedItem(); |
|
|
|
} |
|
|
|
this.updatePlaceItemState(actionData.additionalParams?.button, true); |
|
|
|
|
|
|
|
this.map.once('pm:create', (e) => { |
|
|
|
@ -700,7 +706,7 @@ export abstract class TbMap<S extends BaseMapSettings> { |
|
|
|
// @ts-ignore
|
|
|
|
e.layer._pmTempLayer = true; |
|
|
|
e.layer.remove(); |
|
|
|
this.finishAdd(); |
|
|
|
this.finishCreatedItem(); |
|
|
|
}); |
|
|
|
|
|
|
|
prepareDrawMode(); |
|
|
|
@ -713,10 +719,12 @@ export abstract class TbMap<S extends BaseMapSettings> { |
|
|
|
iconClass: 'tb-close', |
|
|
|
title: this.ctx.translate.instant('action.cancel'), |
|
|
|
showText: true, |
|
|
|
click: this.finishAdd |
|
|
|
click: this.finishCreatedItem |
|
|
|
} |
|
|
|
], false); |
|
|
|
|
|
|
|
this.createMapItemActionId = actionId; |
|
|
|
|
|
|
|
const convertLayerToCoordinates = (type: MapItemType, layer: L.Layer): {x: number; y: number} | TbPolygonRawCoordinates | TbCircleData => { |
|
|
|
switch (type) { |
|
|
|
case MapItemType.marker: |
|
|
|
@ -748,6 +756,11 @@ export abstract class TbMap<S extends BaseMapSettings> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private finishCreatedItem = () => { |
|
|
|
delete this.createMapItemActionId; |
|
|
|
this.finishAdd(); |
|
|
|
} |
|
|
|
|
|
|
|
private finishAdd = () => { |
|
|
|
if (this.currentPopover) { |
|
|
|
this.currentPopover.hide(); |
|
|
|
|