Add support for gpx rendering
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
Alessio Davoli 2023-12-22 12:19:10 +01:00
parent 5c9bba2af5
commit c9faabc945

View file

@ -7,6 +7,7 @@
const pianelloCoordinates = [43.14, 12.53];
let mapElement: string | HTMLElement;
let leaflet;
let leafletGPX;
let map;
let layerGroup;
let latitude;
@ -66,9 +67,10 @@
layerGroup = leaflet.layerGroup();
// Startup Map
map = leaflet.map(mapElement, {
dragging: leaflet.Browser.mobile,
tap: leaflet.Browser.mobile,
//dragging: leaflet.Browser.mobile,
//tap: leaflet.Browser.mobile,
});
map.setView(pianelloCoordinates, 13);
@ -78,11 +80,21 @@
.addTo(map);
}
const renderGPX = () => {
const gpx = "/gpx/tidone.gpx"; // URL to your GPX file or the GPX itself
new leafletGPX(gpx, {async: true}).on('loaded', function(e) {
map.fitBounds(e.target.getBounds());
}).addTo(map);
}
onMount(async () => {
await watchPosition();
leaflet = await import('leaflet');
const {GPX} = await import('leaflet-gpx');
leafletGPX = GPX;
renderMap();
renderGPX();
});
onDestroy(async () => {