[英]why does geolocation not work on mobile browsers and desktop?
I am trying to get the location of the user with HTML5 geolocation.我正在尝试使用 HTML5 地理定位获取用户的位置。 On Desktop Gives this error when I grant access 2: Network location provider at 'https://www.googleapis.com/': No response received.
在桌面上 当我授予访问权限 2 时出现此错误:“https://www.googleapis.com/”的网络位置提供商:未收到回复。 And when I test on a mobile phone, it does not ask the access question and error 1: User denied Geolocation
而且我在手机上测试的时候没有问访问问题和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.我在所有设备上都使用谷歌浏览器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.