Skip to content

Commit

Permalink
modify Leaflet to show tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
derGraph committed Aug 20, 2024
1 parent 39d98c8 commit 24b45c6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Empty file removed src/lib/Leaflet.css
Empty file.
25 changes: 24 additions & 1 deletion src/lib/Leaflet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@
let map: L.Map | undefined;
let mapElement: HTMLDivElement;
interface Datapoint {
id?: string;
time?: Date;
tripId: string;
lat: number;
long: number;
speed?: number;
heading?: number;
depth?: number;
h_accuracy?: number;
v_accuracy?: number;
propulsion?: number;
}
onMount(() => {
map = L.map(mapElement);
Expand All @@ -22,7 +36,7 @@
});
osmLayer.addTo(map);
seamarkLayer.addTo(map);
//seamarkLayer.addTo(map);
});
onDestroy(() => {
Expand All @@ -37,6 +51,7 @@
export let bounds: L.LatLngBoundsExpression | undefined = undefined;
export let view: L.LatLngExpression | undefined = undefined;
export let zoom: number | undefined = undefined;
export let tracks: Datapoint[] | null = null;
onMount(() => {
if (!bounds && (!view || !zoom)) {
Expand All @@ -50,6 +65,14 @@
} else if (view && zoom) {
map.setView(view, zoom);
}
let latlngs: L.LatLng[] = [];
if(tracks != null){
for(let point of tracks){
latlngs.push(new L.LatLng(point.lat, point.long))
}
let polyline = L.polyline(latlngs, {color: 'red'}).addTo(map);
}
}
</script>

Expand Down

0 comments on commit 24b45c6

Please sign in to comment.