From 35937a933cb2ae6e92330240e202724d0ad5b2d3 Mon Sep 17 00:00:00 2001 From: evlist Date: Tue, 29 Nov 2022 21:19:28 +0100 Subject: [PATCH] Changing the selection UI. --- src/components/map/Map.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/map/Map.tsx b/src/components/map/Map.tsx index f9d4d10..e5e473f 100644 --- a/src/components/map/Map.tsx +++ b/src/components/map/Map.tsx @@ -146,6 +146,8 @@ const Map: Component = () => { } }); + let selectedFeatures: Feature[] = []; + const clickHandler = (event: any) => { const pixel = [event.originalEvent.x, event.originalEvent.y]; const features = event.map.getFeaturesAtPixel(pixel, { hitTolerance: 30 }); @@ -155,9 +157,11 @@ const Map: Component = () => { features, tree: unwrap(tree), }); + selectedFeatures.map((feature) => feature.set('isSelected', false)); + selectedFeatures = features; features.map((feature) => { const id = feature.get('id'); - feature.set('isSelected', !feature.get('isSelected')); + feature.set('isSelected', true); console.log({ caller: 'clickHandler / feature', event, feature, id }); const branch = tree[id]; if (branch?.updateHandler) branch.updateHandler(feature);