From 5d079e12080196c3e8b071acb74cc79697c910cc Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 8 Jun 2024 19:35:03 -0500 Subject: [PATCH] Tell user to refresh the page, if access to location has failed at least in my local firefox on laptop, it would not prompt user again until page was refreshed --- src/views/HomeView.vue | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 33b6d30..55872e0 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -11,6 +11,7 @@ export default { return { coordinates: null, loading: false, + locationAccessBlocked: false, } }, @@ -22,13 +23,19 @@ export default { useCurrentLocation() { - if (location.protocol == 'http:') { - alert("Sorry, this only works for secure sites.") + if (this.locationAccessBlocked) { + alert("You must refresh the page first, then try again.") + return } navigator.geolocation.getCurrentPosition(loc => { this.coordinates = `${loc.coords.latitude},${loc.coords.longitude}` this.loadCoordinates() + }, error => { + if (error.code == 1) { // PERMISSION_DENIED + this.locationAccessBlocked = true + } + alert(`error.code = ${error.code}\n\n${error.message}`) }) },