【发布时间】:2017-11-30 02:13:49
【问题描述】:
我正在尝试使用 HTML 地理位置来获取我的位置。有趣的是,它工作得非常出色,直到有一天它停止工作的某个看似随机的时刻。现在我得到的只是带有消息的错误回调:
Unknown error acquiring position
这发生在我第一次开始开发应用程序的那天。它是一个内置在 Node/Express 中的网络应用程序。我使用的浏览器是 Firefox v53 64-bit。
位置是允许的,我还尝试了一个我在网上找到的修复方法,它涉及到 about:config 并将 geo.wifi.uri 更改为:
https://www.googleapis.com/geolocation/v1/geolocate?key=%GOOGLE_API_KEY%
到
https://www.googleapis.com/geolocation/v1/geolocate?key=test
这对我不起作用。
不过,这在我的手机 Firefox 应用上有效,但在 Google Chrome 应用上无效。
这是一个示例代码sn-p:
const geo = navigator.geolocation;
geo.getCurrentPosition(success, failure);
function success(position) {
lat = position.coords.latitude;
lng = position.coords.longitude;
$('#coords').val(lat + ',' + lng);
mapView.setCenter(ol.proj.fromLonLat([lng, lat]));
}
function failure(error) {
console.log(error.message);
}
全文:https://github.com/ThriceGood/Spots/blob/master/views/index.html
谁能解释一下这个问题?
【问题讨论】:
-
and changing the line- 那是哪个配置项!!?? -
对不起,它的:
geo.wifi.uri -
好吧,我的是
https://location.services.mozilla.com/v1/geolocate?key=%MOZILLA_API_KEY%——注意它根本不使用googleapi的!!!另外,我的手机中根本不存在该配置项 -
谢谢。似乎将该 uri 用于我的位置服务并不能为我解决问题。
标签: javascript html firefox geolocation google-geolocation