Add "Add as waypoint" button to POI popups
Clicking the button in a POI popup adds the POI's location and name as a new waypoint at the end of the route. Uses event delegation on the map container to handle clicks on dynamically created popup buttons. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8c3fc36d23
commit
3af6aee32c
2 changed files with 24 additions and 3 deletions
|
|
@ -361,11 +361,12 @@ export function PlannerMap({ yjs, onRouteRequest, highlightPosition, highlighted
|
|||
}, [yjs.routeData]);
|
||||
|
||||
const addWaypoint = useCallback(
|
||||
(lat: number, lng: number) => {
|
||||
(lat: number, lng: number, name?: string) => {
|
||||
yjs.doc.transact(() => {
|
||||
const yMap = new Y.Map();
|
||||
yMap.set("lat", lat);
|
||||
yMap.set("lon", lng);
|
||||
if (name) yMap.set("name", name);
|
||||
yjs.waypoints.push([yMap]);
|
||||
}, "local");
|
||||
},
|
||||
|
|
@ -512,7 +513,7 @@ export function PlannerMap({ yjs, onRouteRequest, highlightPosition, highlighted
|
|||
<NoGoAreaLayer noGoAreas={yjs.noGoAreas} doc={yjs.doc} enabled={noGoDrawing} onToggle={toggleNoGoDraw} />
|
||||
<NoGoAreaButton active={noGoDrawing} onClick={toggleNoGoDraw} />
|
||||
<PoiRefresher poiState={poiState} />
|
||||
<PoiMarkers poiState={poiState} />
|
||||
<PoiMarkers poiState={poiState} onAddWaypoint={addWaypoint} />
|
||||
<PoiPanel poiState={poiState} />
|
||||
|
||||
{waypoints.map((wp, i) => (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue