diff --git a/src/lib/components/Map/LocationRequest.svelte b/src/lib/components/Map/LocationRequest.svelte
index ff3e427..ceaec32 100644
--- a/src/lib/components/Map/LocationRequest.svelte
+++ b/src/lib/components/Map/LocationRequest.svelte
@@ -1,57 +1,71 @@
-
-{#if state === 'not-granted'}
-
- This is an info alert
-
-
Please provide Erant your location
-
-
-
-
-
-{/if}
-
-{#if state === 'granted'}
-
-{/if}
\ No newline at end of file
+
+ {#if state === 'not-granted'}
+
+ This is an info alert
+
+
Please provide Erant your location
+
+
+
+
+
+ {/if}
+
+ {#if state === 'granted'}
+
+ {/if}
\ No newline at end of file
diff --git a/src/routes/map.svelte b/src/routes/map.svelte
index c801730..825b0c3 100644
--- a/src/routes/map.svelte
+++ b/src/routes/map.svelte
@@ -4,22 +4,26 @@
import LocationRequest from '$lib/components/Map/LocationRequest.svelte'
import { onMount } from 'svelte'
- let user = { lat: 50.073658, lng: 14.41854 }
let granted = false
+ let user = null
+
+ const handleLocationGranted = (position: GeolocationPosition) => {
+ user = { lat: position.coords.latitude, lng: position.coords.longitude }
+ granted = true
+ }
onMount(() => {
- navigator.permissions.query({ name: 'geolocation' })
- .then(permissionStatus => {
- if (permissionStatus.state === 'granted') {
- granted = true
- } else {
- granted = false
+ const storedPermission = localStorage.getItem('locationPermission')
+ if (storedPermission === 'granted') {
+ navigator.geolocation.getCurrentPosition(
+ (position) => {
+ handleLocationGranted(position)
+ },
+ (error) => {
+ console.log(error)
}
- })
- .catch(error => {
- console.error(error)
- granted = false
- })
+ )
+ }
})
@@ -27,6 +31,6 @@
{#if granted}
{:else}
- (granted = true)} />
+
{/if}
-
+
\ No newline at end of file