Compare commits
2 commits
76d9f46fa5
...
c9faabc945
Author | SHA1 | Date | |
---|---|---|---|
c9faabc945 | |||
5c9bba2af5 |
3 changed files with 21 additions and 2 deletions
6
frontend/package-lock.json
generated
6
frontend/package-lock.json
generated
|
@ -9,6 +9,7 @@
|
||||||
"version": "0.6.0",
|
"version": "0.6.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"leaflet": "^1.9.4",
|
"leaflet": "^1.9.4",
|
||||||
|
"leaflet-gpx": "^1.7.0",
|
||||||
"svelte-preprocess": "^5.1.3"
|
"svelte-preprocess": "^5.1.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -2367,6 +2368,11 @@
|
||||||
"resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.9.4.tgz",
|
"resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.9.4.tgz",
|
||||||
"integrity": "sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA=="
|
"integrity": "sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA=="
|
||||||
},
|
},
|
||||||
|
"node_modules/leaflet-gpx": {
|
||||||
|
"version": "1.7.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/leaflet-gpx/-/leaflet-gpx-1.7.0.tgz",
|
||||||
|
"integrity": "sha512-5NS5WKfp5zaAHMB2KM6OUaIng+SZ3e/UHK2++ABl2wELojYlmLqIL8t1Mj6DaZGkIh3kld+mAUvMGdIzC1yGRA=="
|
||||||
|
},
|
||||||
"node_modules/levn": {
|
"node_modules/levn": {
|
||||||
"version": "0.4.1",
|
"version": "0.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"leaflet": "^1.9.4",
|
"leaflet": "^1.9.4",
|
||||||
|
"leaflet-gpx": "^1.7.0",
|
||||||
"svelte-preprocess": "^5.1.3"
|
"svelte-preprocess": "^5.1.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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