【发布时间】:2015-11-26 15:09:45
【问题描述】:
我正在开发跨平台应用程序。 navigator.geolocation 工作正常,但从过去 2 天开始,它只是在 Google chrome 中出现问题。 该 api 是否已弃用或此 api 的其他问题?我在许多不同的浏览器和网络上测试了以下代码,但仍然是同样的问题。
var options = {
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0
};
function success(pos) {
var crd = pos.coords;
console.log('Your current position is:');
console.log('Latitude : ' + crd.latitude);
console.log('Longitude: ' + crd.longitude);
console.log('More or less ' + crd.accuracy + ' meters.');
};
function error(err) {
console.warn('ERROR(' + err.code + '): ' + err.message);
};
navigator.geolocation.getCurrentPosition(success, error, options);
ERROR(2): 'https://www.googleapis.com/' 处的网络位置提供程序:返回错误代码 403。
【问题讨论】:
-
googleapis.com 不存在。 ajax.googleapis.com 确实如此。你在尝试to use one of these libraries吗?
-
你也得到...
getCurrentPosition() and watchPosition() are deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details. -
我遇到了同样的问题。 OS X 上的 Chrome 44 最新版本。我在外部站点上收到了不安全的弃用警告,但在本地运行时没有这样的警告(通过 file:// 协议或 localhost)。同样的 403 错误,同样的消息。
-
不,它只是给了我一个错误:ERROR(2): Network location provider at 'googleapis.com' : Returned error code 403.
-
是的,我认为这可能是问题所在。 2 个月前 chrome 43 还更改了一些 api,导致 sencha touch 滚动出现问题。
标签: javascript google-chrome geolocation w3c-geolocation