From fdd174b21a1e72c3c9eec8c2fd959732d4cd110e Mon Sep 17 00:00:00 2001 From: Candid Dauth Date: Sat, 2 Mar 2024 15:35:06 +0100 Subject: [PATCH] Fix type error --- frontend/src/lib/utils/draw.ts | 6 +++--- leaflet/src/markers/markers-layer.ts | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/utils/draw.ts b/frontend/src/lib/utils/draw.ts index 77dcfc78..90066961 100644 --- a/frontend/src/lib/utils/draw.ts +++ b/frontend/src/lib/utils/draw.ts @@ -39,7 +39,7 @@ export function moveMarker(markerId: ID, context: FacilMapContext, toasts: Toast const mapContext = requireMapContext(context); const client = requireClientContext(context); - const markerLayer = mapContext.value.components.markersLayer.markersById[markerId]; + const markerLayer = mapContext.value.components.markersLayer.getLayerByMarkerId(markerId); if(!markerLayer) return; @@ -48,7 +48,7 @@ export function moveMarker(markerId: ID, context: FacilMapContext, toasts: Toast mapContext.value.components.map.fire('fmInteractionStart'); mapContext.value.components.markersLayer.lockMarker(markerId); - async function finish(save: boolean) { + const finish = async (save: boolean) => { toasts.hideToast("fm-draw-drag-marker"); markerLayer.dragging!.disable(); @@ -64,7 +64,7 @@ export function moveMarker(markerId: ID, context: FacilMapContext, toasts: Toast mapContext.value.components.markersLayer.unlockMarker(markerId); mapContext.value.components.map.fire('fmInteractionEnd'); - } + }; toasts.showToast("fm-draw-drag-marker", "Drag marker", "Drag the marker to reposition it.", { noCloseButton: true, diff --git a/leaflet/src/markers/markers-layer.ts b/leaflet/src/markers/markers-layer.ts index ceef2362..12c9be62 100644 --- a/leaflet/src/markers/markers-layer.ts +++ b/leaflet/src/markers/markers-layer.ts @@ -142,6 +142,10 @@ export default class MarkersLayer extends MarkerCluster { this._deleteMarker(this.client.markers[id]); } + getLayerByMarkerId(markerId: ID): MarkerLayer | undefined { + return this.markersById[markerId]; + } + protected _addMarker(marker: Marker): void { const updatePos = !this.markersById[marker.id] || !this.lockedMarkerIds.has(marker.id);