Update MapTab component
This commit is contained in:
parent
53002630c1
commit
cc8bf87f3e
1 changed files with 11 additions and 5 deletions
|
@ -10,10 +10,13 @@
|
||||||
let latitude;
|
let latitude;
|
||||||
let longitude;
|
let longitude;
|
||||||
let accuracy;
|
let accuracy;
|
||||||
|
const errorMessage = "Geolocation not available";
|
||||||
|
let errored = false;
|
||||||
|
|
||||||
const loadWorker = async () => {
|
const watchPosition = async () => {
|
||||||
if (!("geolocation" in navigator)) {
|
if (!("geolocation" in navigator)) {
|
||||||
return;
|
errored = true;
|
||||||
|
throw new Error(errorMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
|
@ -45,7 +48,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
await loadWorker();
|
await watchPosition();
|
||||||
leaflet = await import('leaflet');
|
leaflet = await import('leaflet');
|
||||||
layerGroup = leaflet.layerGroup();
|
layerGroup = leaflet.layerGroup();
|
||||||
|
|
||||||
|
@ -75,8 +78,11 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
{#if !errored}
|
||||||
<div id="map" in:fade bind:this={mapElement} />
|
<div id="map" in:fade bind:this={mapElement} />
|
||||||
|
{:else}
|
||||||
|
{errorMessage}
|
||||||
|
{/if}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@import 'leaflet/dist/leaflet.css';
|
@import 'leaflet/dist/leaflet.css';
|
||||||
|
|
Loading…
Reference in a new issue