Skip to content

Commit efaeadb

Browse files
route from current location (motis backport)
1 parent ccd00e2 commit efaeadb

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/routes/(customer)/routing/+page.svelte

+23-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
import { updateStartDest } from '$lib/util/updateStartDest';
4141
import { odmPrice } from '$lib/util/odmPrice';
4242
import BookingSummary from '$lib/ui/BookingSummary.svelte';
43+
import { LocateFixed } from 'lucide-svelte';
44+
import { posToLocation } from '$lib/map/Location';
4345
4446
type LuggageType = 'none' | 'light' | 'heavy';
4547
@@ -137,6 +139,18 @@
137139
}
138140
pushState('', { selectedItinerary: itinerary });
139141
};
142+
143+
const getLocation = () => {
144+
if (navigator && navigator.geolocation) {
145+
navigator.geolocation.getCurrentPosition(applyPosition, (e) => console.log(e), {
146+
enableHighAccuracy: true
147+
});
148+
}
149+
};
150+
151+
const applyPosition = (position: { coords: { latitude: number; longitude: number } }) => {
152+
from = posToLocation({ lat: position.coords.latitude, lon: position.coords.longitude }, 0);
153+
};
140154
</script>
141155

142156
<div class="md:min-h-[70dvh] md:w-96">
@@ -291,7 +305,15 @@
291305
value={to.label}
292306
/>
293307
<Button
294-
class="absolute right-4 top-6 z-10 rounded-full"
308+
variant="ghost"
309+
class="absolute z-10 right-0 top-0"
310+
size="icon"
311+
onclick={() => getLocation()}
312+
>
313+
<LocateFixed class="w-5 h-5" />
314+
</Button>
315+
<Button
316+
class="absolute right-10 top-6 z-10 rounded-full"
295317
size="icon"
296318
onclick={() => {
297319
const tmp = to;

0 commit comments

Comments
 (0)