Changing the selection UI.

This commit is contained in:
Eric van der Vlist 2022-11-29 21:19:28 +01:00
parent 82cdad5f1f
commit 35937a933c
1 changed files with 5 additions and 1 deletions

View File

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