diff --git a/src/components/wpt/Wpt.tsx b/src/components/wpt/Wpt.tsx index 12e1c58..53f5b1e 100644 --- a/src/components/wpt/Wpt.tsx +++ b/src/components/wpt/Wpt.tsx @@ -83,9 +83,13 @@ export const Wpt: Component = ({ vectorSource, wptId: wptId }) => { }; createEffect(() => { - console.log({ caller: 'Wpt', vectorSource, wptId, wpt: wpt() }); + console.log({ caller: 'Wpt', vectorSource, wptId, wpt: cloneDeep(wpt()) }); - if (wpt() && !tree[wptId]) { + if (wpt() /* && !tree[wptId] */) { + const existingFeature = vectorSource.getFeatureById(wptId); + if (existingFeature) { + vectorSource.removeFeature(existingFeature); + } let geo: any = { type: 'FeatureCollection', features: [ @@ -96,6 +100,7 @@ export const Wpt: Component = ({ vectorSource, wptId: wptId }) => { coordinates: [wpt()?.$.lon, wpt()?.$.lat], }, properties: { type: 'wpt', ...wpt(), id: wptId, getTitle, edit }, + id: wptId, }, ], }; @@ -103,7 +108,7 @@ export const Wpt: Component = ({ vectorSource, wptId: wptId }) => { const features = new GeoJSON().readFeatures(geo); console.log({ caller: 'Wpt', features }); vectorSource.addFeatures(features); - setBranch(wptId, { features, updateHandler }); + // setBranch(wptId, { features, updateHandler }); } });