Add support for gpx rendering
All checks were successful
ci/woodpecker/push/build Pipeline was successful
All checks were successful
ci/woodpecker/push/build Pipeline was successful
This commit is contained in:
parent
5c9bba2af5
commit
c9faabc945
1 changed files with 14 additions and 2 deletions
|
@ -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 () => {
|
||||
|
|
Loading…
Reference in a new issue