Stack Overflow Asked by morteza on December 6, 2020
I am trying to get the location of the user with HTML5 geolocation. On Desktop Gives this error when I grant access 2: Network location provider at ‘https://www.googleapis.com/’: No response received. And when I test on a mobile phone, it does not ask the access question and error 1: User denied Geolocation
this is my code:
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 using Google Chrome on all devices.
Answered by Yutong Zhang on December 6, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP