From a761d16fcd9c3ee6be54e0cbab89b3e44a4189ea Mon Sep 17 00:00:00 2001 From: Gjore Milevski Date: Thu, 24 Oct 2024 11:01:32 +0200 Subject: [PATCH 1/2] Test if preselecting of the selected AOIs works --- .../common/map/controls/aoi/custom-aoi-control.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/scripts/components/common/map/controls/aoi/custom-aoi-control.tsx b/app/scripts/components/common/map/controls/aoi/custom-aoi-control.tsx index c31ad4d54..141ce7d29 100644 --- a/app/scripts/components/common/map/controls/aoi/custom-aoi-control.tsx +++ b/app/scripts/components/common/map/controls/aoi/custom-aoi-control.tsx @@ -89,7 +89,14 @@ function CustomAoI({ const mbDraw = map?._drawControl; if (!mbDraw) return; const aoiSelectedFor = selectedForEditing ? SIMPLE_SELECT : STATIC_MODE; - mbDraw.changeMode(aoiSelectedFor); + const selectedFeatures = features.filter(f => f.selected); + + if (selectedFeatures.length > 0) { + const selectedIds = selectedFeatures.map(f => f.id); + mbDraw.changeMode(aoiSelectedFor, { + featureIds: selectedIds + }); + } const onSelChange = () => forceUpdate(Date.now()); map.on('draw.selectionchange', onSelChange); return () => { From 71abffc43687da1771f98d8f9d39a7d26c459e5d Mon Sep 17 00:00:00 2001 From: Gjore Milevski Date: Tue, 29 Oct 2024 09:30:56 +0100 Subject: [PATCH 2/2] Remove deps --- .../components/common/map/controls/aoi/custom-aoi-control.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/scripts/components/common/map/controls/aoi/custom-aoi-control.tsx b/app/scripts/components/common/map/controls/aoi/custom-aoi-control.tsx index 141ce7d29..9d5a5ae18 100644 --- a/app/scripts/components/common/map/controls/aoi/custom-aoi-control.tsx +++ b/app/scripts/components/common/map/controls/aoi/custom-aoi-control.tsx @@ -102,7 +102,7 @@ function CustomAoI({ return () => { map.off('draw.selectionchange', onSelChange); }; - }, [map, selectedForEditing]); + }, [selectedForEditing]); const resetAoisOnMap = useCallback(() => { const mbDraw = map?._drawControl;