Update MapTab component

This commit is contained in:
Alessio Davoli 2023-07-19 14:43:45 +02:00
parent 53002630c1
commit cc8bf87f3e

View file

@ -10,10 +10,13 @@
let latitude;
let longitude;
let accuracy;
const errorMessage = "Geolocation not available";
let errored = false;
const loadWorker = async () => {
const watchPosition = async () => {
if (!("geolocation" in navigator)) {
return;
errored = true;
throw new Error(errorMessage)
}
const options = {
@ -45,7 +48,7 @@
};
onMount(async () => {
await loadWorker();
await watchPosition();
leaflet = await import('leaflet');
layerGroup = leaflet.layerGroup();
@ -75,8 +78,11 @@
}
});
</script>
{#if !errored}
<div id="map" in:fade bind:this={mapElement} />
{:else}
{errorMessage}
{/if}
<style>
@import 'leaflet/dist/leaflet.css';