This commit is contained in:
parent
6a28949f41
commit
e516f9fce5
1 changed files with 6 additions and 3 deletions
|
@ -2,11 +2,13 @@
|
||||||
import { onMount, onDestroy } from 'svelte';
|
import { onMount, onDestroy } from 'svelte';
|
||||||
import { fade, fly } from 'svelte/transition';
|
import { fade, fly } from 'svelte/transition';
|
||||||
|
|
||||||
const parmaCoordinates = [44.8, 10.32];
|
|
||||||
let mapElement: string | HTMLElement;
|
let mapElement: string | HTMLElement;
|
||||||
let leaflet;
|
let leaflet;
|
||||||
let map;
|
let map;
|
||||||
let layerGroup;
|
let layerGroup;
|
||||||
|
let latitude;
|
||||||
|
let longitude;
|
||||||
|
let accuracy;
|
||||||
|
|
||||||
const loadWorker = async () => {
|
const loadWorker = async () => {
|
||||||
if (!("geolocation" in navigator)) {
|
if (!("geolocation" in navigator)) {
|
||||||
|
@ -45,6 +47,7 @@
|
||||||
|
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
await loadWorker();
|
||||||
leaflet = await import('leaflet');
|
leaflet = await import('leaflet');
|
||||||
layerGroup = leaflet.layerGroup();
|
layerGroup = leaflet.layerGroup();
|
||||||
|
|
||||||
|
@ -55,7 +58,7 @@
|
||||||
minZoom: 12
|
minZoom: 12
|
||||||
});
|
});
|
||||||
|
|
||||||
map.setView(parmaCoordinates, 13);
|
map.setView([latitude, longitude], 13);
|
||||||
map.setMaxBounds(map.getBounds());
|
map.setMaxBounds(map.getBounds());
|
||||||
|
|
||||||
leaflet
|
leaflet
|
||||||
|
@ -65,7 +68,7 @@
|
||||||
})
|
})
|
||||||
.addTo(map);
|
.addTo(map);
|
||||||
|
|
||||||
loadWorker();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onDestroy(async () => {
|
onDestroy(async () => {
|
||||||
|
|
Loading…
Reference in a new issue