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];
|
const pianelloCoordinates = [43.14, 12.53];
|
||||||
let mapElement: string | HTMLElement;
|
let mapElement: string | HTMLElement;
|
||||||
let leaflet;
|
let leaflet;
|
||||||
|
let leafletGPX;
|
||||||
let map;
|
let map;
|
||||||
let layerGroup;
|
let layerGroup;
|
||||||
let latitude;
|
let latitude;
|
||||||
|
@ -66,9 +67,10 @@
|
||||||
layerGroup = leaflet.layerGroup();
|
layerGroup = leaflet.layerGroup();
|
||||||
|
|
||||||
// Startup Map
|
// Startup Map
|
||||||
|
|
||||||
map = leaflet.map(mapElement, {
|
map = leaflet.map(mapElement, {
|
||||||
dragging: leaflet.Browser.mobile,
|
//dragging: leaflet.Browser.mobile,
|
||||||
tap: leaflet.Browser.mobile,
|
//tap: leaflet.Browser.mobile,
|
||||||
});
|
});
|
||||||
|
|
||||||
map.setView(pianelloCoordinates, 13);
|
map.setView(pianelloCoordinates, 13);
|
||||||
|
@ -78,11 +80,21 @@
|
||||||
.addTo(map);
|
.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 () => {
|
onMount(async () => {
|
||||||
await watchPosition();
|
await watchPosition();
|
||||||
leaflet = await import('leaflet');
|
leaflet = await import('leaflet');
|
||||||
|
const {GPX} = await import('leaflet-gpx');
|
||||||
|
leafletGPX = GPX;
|
||||||
|
|
||||||
renderMap();
|
renderMap();
|
||||||
|
renderGPX();
|
||||||
});
|
});
|
||||||
|
|
||||||
onDestroy(async () => {
|
onDestroy(async () => {
|
||||||
|
|
Loading…
Reference in a new issue