Skip to content

Commit

Permalink
show active track on homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
derGraph committed Aug 20, 2024
1 parent 24b45c6 commit 0e481cb
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,30 @@
// @ts-ignore
import type { LatLngExpression } from 'leaflet';
import Leaflet from '$lib/Leaflet.svelte';
import { onMount } from 'svelte';
import errorStore from '$lib/errorStore.js';
export let data;
let tracks: null = null;
const initialView: LatLngExpression = [43.95, 14.79];
async function getTrip(tripId: String) {
let response = await fetch('/api/Datapoints?tripId='+tripId);
if(!response.ok){
$errorStore = response;
}
tracks = await response.json();
}
onMount(()=>{
if(data.user){
getTrip(data.user?.activeTripId);
}
});
</script>

<div class="md:container md:mx-auto py-3 h-full rounded">
<Leaflet view={initialView} zoom={8} />
<Leaflet view={initialView} zoom={8} tracks={tracks}/>
</div>

0 comments on commit 0e481cb

Please sign in to comment.