From 3be44a68727ca6cfde0b38bccc3ea8a7f23c8ca5 Mon Sep 17 00:00:00 2001 From: Anton Tranelis Date: Mon, 6 May 2024 09:50:39 +0200 Subject: [PATCH] open map popup, when item popup opens --- src/Components/Profile/OverlayItemProfile.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Components/Profile/OverlayItemProfile.tsx b/src/Components/Profile/OverlayItemProfile.tsx index d544a3f2..48ed5aed 100644 --- a/src/Components/Profile/OverlayItemProfile.tsx +++ b/src/Components/Profile/OverlayItemProfile.tsx @@ -110,25 +110,29 @@ export function OverlayItemProfile() { useEffect(() => { + const setMap = async (marker, x) => { + await map.setView(new LatLng(item?.position?.coordinates[1]!, item?.position?.coordinates[0]! + x / 4), undefined); + setTimeout(() => { + marker.openPopup(); + }, 300); + } if (item) { if (item.position) { const marker = Object.entries(leafletRefs).find(r => r[1].item == item)?.[1].marker; marker && clusterRef.hasLayer(marker) && clusterRef?.zoomToShowLayer(marker, () => { const bounds = map.getBounds(); const x = bounds.getEast() - bounds.getWest(); - map.setView(new LatLng(item?.position?.coordinates[1]!, item?.position?.coordinates[0]! + x / 4), undefined, { duration: 1 }); + setMap(marker, x); } ); } else { - const parent = getFirstAncestor(item); - const marker = Object.entries(leafletRefs).find(r => r[1].item == parent)?.[1].marker; marker && clusterRef.hasLayer(marker) && clusterRef?.zoomToShowLayer(marker, () => { const bounds = map.getBounds(); const x = bounds.getEast() - bounds.getWest(); - map.setView(new LatLng(parent?.position?.coordinates[1]!, parent?.position?.coordinates[0]! + x / 4), undefined, { duration: 1 }); + setMap(marker, x); } ); } @@ -341,8 +345,6 @@ export function OverlayItemProfile() { - - )} {updatePermission && }