I am encountering an issue while attempting to retrieve the user's location using HTML5 geolocation. When I try on a desktop, it gives me an error saying "Network location provider at 'https://www.googleapis.com/': No response received" after granting access. On mobile, no access question is asked and instead, it throws an error "User denied Geolocation".
Below is the code snippet I am using:
successHandler(position) {
console.log(position)
alert(position.coords.latitude)
alert(position.coords.longitude)
},
errorHandler(errorObj) {
alert(errorObj.code + ": " + errorObj.message);
},
getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(this.successHandler, this.errorHandler, {
enableHighAccuracy: true,
maximumAge: 10000,
timeout: 10000
})
} else {
alert("Geolocation is not supported by this browser.");
}
}
created() {
this.getLocation()
},
I am utilizing Google Chrome as the browser on all devices.