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 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';
|
||||
|
|
Loading…
Reference in a new issue