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);