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
This commit is contained in:
parent
c2e6bfcfdd
commit
5d079e1208
1 changed files with 9 additions and 2 deletions
|
@ -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}`)
|
||||
})
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue