Files
gpx.studio/website/src/lib/components/GPX.svelte

30 lines
478 B
Svelte
Raw Normal View History

2024-04-16 22:57:28 +02:00
<script lang="ts">
import { GPXFile } from 'gpx';
2024-04-17 11:44:37 +02:00
import { map } from '$lib/stores';
2024-04-16 22:57:28 +02:00
export let file: GPXFile;
2024-04-17 11:44:37 +02:00
$: if ($map) {
$map.on('load', () => {
$map.addSource('gpx', {
2024-04-16 22:57:28 +02:00
type: 'geojson',
data: file.toGeoJSON()
});
2024-04-17 11:44:37 +02:00
$map.addLayer({
2024-04-16 22:57:28 +02:00
id: 'gpx',
type: 'line',
source: 'gpx',
layout: {
'line-join': 'round',
'line-cap': 'round'
},
paint: {
'line-color': '#888',
'line-width': 8
}
});
});
}
</script>