我正在尝试使用HTML地理定位来获取我的位置。有趣的是,它一直工作得非常好,直到某个看似随机的时间点突然停止工作。现在,我只能得到一个错误回调和一个消息:
Unknown error acquiring position
这件事发生在我第一次开始开发这个应用程序的那天。这是一个使用Node/Express构建的Web应用程序。我正在使用Firefox v53 64位浏览器。
位置信息已被允许,并且我也尝试了在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应用程序无法使用。
这是一个示例代码片段:
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
有人能够解决这个问题吗?
geo.wifi.uri
。 - ThriceGoodhttps://location.services.mozilla.com/v1/geolocate?key=%MOZILLA_API_KEY%
- 注意它完全没有使用googleapi!此外,在我的手机上根本不存在该配置项。 - Jaromanda X