[英]why does geolocation not work on mobile browsers and desktop?
我正在嘗試使用 HTML5 地理定位獲取用戶的位置。 在桌面上 當我授予訪問權限 2 時出現此錯誤:“https://www.googleapis.com/”的網絡位置提供商:未收到回復。 而且我在手機上測試的時候沒有問訪問問題和error 1: User denied Geolocation
這是我的代碼:
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()
},
我在所有設備上都使用谷歌瀏覽器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.