Store POI metadata (osmId, tags) on waypoints for Journal use

When a waypoint is created from or snapped to a POI, the Yjs Y.Map
now stores osmId (OSM node ID) and poiTags (phone, website, address,
opening hours, etc.). Dragging away clears this data.

This persists through the Yjs document and will be available when the
route is saved to the Journal, enabling future display of campsite
contact details, opening hours, etc. on route detail pages.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-04-11 02:02:47 +02:00
parent a71efef1ce
commit 6d82ebe127
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9
2 changed files with 27 additions and 3 deletions

View file

@ -363,13 +363,15 @@ export function PlannerMap({ yjs, onRouteRequest, highlightPosition, highlighted
const addWaypoint = useCallback(
(lat: number, lng: number, name?: string) => {
const snap = name ? { lat, lon: lng, name, snapped: false } : snapToPoi(lat, lng, poiState.pois);
const snap = snapToPoi(lat, lng, poiState.pois);
yjs.doc.transact(() => {
const yMap = new Y.Map();
yMap.set("lat", snap.lat);
yMap.set("lon", snap.snapped ? snap.lon : lng);
if (snap.name) yMap.set("name", snap.name);
else if (name) yMap.set("name", name);
else if (name) yMap.set("name", name); // fallback for explicit name
if (snap.osmId) yMap.set("osmId", snap.osmId);
if (snap.poiTags) yMap.set("poiTags", snap.poiTags);
yjs.waypoints.push([yMap]);
}, "local");
},
@ -410,6 +412,13 @@ export function PlannerMap({ yjs, onRouteRequest, highlightPosition, highlighted
} else {
yMap.delete("name");
}
if (snap.osmId) {
yMap.set("osmId", snap.osmId);
if (snap.poiTags) yMap.set("poiTags", snap.poiTags);
} else {
yMap.delete("osmId");
yMap.delete("poiTags");
}
}, "local");
}
},