aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/app/routes/planner.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/app/routes/planner.tsx')
-rw-r--r--src/frontend/app/routes/planner.tsx28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/frontend/app/routes/planner.tsx b/src/frontend/app/routes/planner.tsx
index 5121dce..55d1553 100644
--- a/src/frontend/app/routes/planner.tsx
+++ b/src/frontend/app/routes/planner.tsx
@@ -754,6 +754,8 @@ export default function PlannerPage() {
selectedItineraryIndex,
selectItinerary,
deselectItinerary,
+ setOrigin,
+ setDestination,
} = usePlanner();
const [selectedItinerary, setSelectedItinerary] = useState<Itinerary | null>(
null
@@ -839,7 +841,31 @@ export default function PlannerPage() {
</p>
)}
</div>
- <button onClick={clearRoute} className="text-sm text-red-500">
+ <button
+ onClick={() => {
+ clearRoute();
+ setDestination(null);
+ if (navigator.geolocation) {
+ navigator.geolocation.getCurrentPosition(
+ async (pos) => {
+ const initial = {
+ name: t("planner.current_location"),
+ label: "GPS",
+ lat: pos.coords.latitude,
+ lon: pos.coords.longitude,
+ layer: "current-location",
+ } as any;
+ setOrigin(initial);
+ },
+ () => {
+ // If geolocation fails, just keep origin empty
+ },
+ { enableHighAccuracy: true, timeout: 10000 }
+ );
+ }
+ }}
+ className="text-sm text-red-500"
+ >
{t("planner.clear")}
</button>
</div>