-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Default to IP if user denied geolocation services Added circle spinner while loading data
- Loading branch information
1 parent
005c314
commit dcb62c7
Showing
1 changed file
with
18 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,28 @@ | ||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
import IconCircleSpinner from '../icons/icon-circle-spinner.vue' | ||
import Button from '@/components/atoms/Button.vue' | ||
import GeolocationIcon from '@/components/icons/icon-geolocation.vue' | ||
import MinusIcon from '@/components/icons/icon-minus.vue' | ||
import PlusIcon from '@/components/icons/icon-plus.vue' | ||
import { useGeoIp } from '@/composables/useGeoLocation' | ||
import { useMap } from '@/stores/map' | ||
const { browserPositionIsSupported, geolocateUserViaBrowser, geolocatingUserBrowser } = useGeoIp() | ||
const isGeolocationLoading = ref(false) | ||
const { browserPositionIsSupported, ipPosition, ipPositionError, geolocateIp, geolocateUserViaBrowser, geolocatingUserBrowser, errorBrowser } = useGeoIp() | ||
async function setBrowserPosition() { | ||
isGeolocationLoading.value = true | ||
const browserPosition = await geolocateUserViaBrowser() | ||
if (errorBrowser.value) { | ||
alert(`${errorBrowser.value.message}. Moving to closest location`) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Albermonte
Author
Member
|
||
await geolocateIp() | ||
if (!ipPositionError.value && ipPosition.value) | ||
useMap().setPosition(ipPosition.value) | ||
isGeolocationLoading.value = false | ||
return | ||
} | ||
isGeolocationLoading.value = false | ||
This comment has been minimized.
Sorry, something went wrong.
onmax
Member
|
||
useMap().setPosition(browserPosition) | ||
} | ||
</script> | ||
|
@@ -19,10 +32,12 @@ async function setBrowserPosition() { | |
<Button | ||
v-if="browserPositionIsSupported" | ||
:disabled="geolocatingUserBrowser" style="width: 34px; height: 34px" bg-color="white" size="sm" :aria-label="$t('Show your location')" | ||
:title="$t('Show your location')" @click="setBrowserPosition" | ||
:title="$t('Show your location')" | ||
@click="setBrowserPosition" | ||
> | ||
<template #icon> | ||
<GeolocationIcon /> | ||
<GeolocationIcon v-if="!isGeolocationLoading" /> | ||
<IconCircleSpinner v-else class="w-4 h-4 text-space" /> | ||
</template> | ||
</Button> | ||
|
||
|
Can we remove the alert? I don't think is neccesary tbh @Albermonte