【发布时间】:2016-11-28 21:49:35
【问题描述】:
我通过navigator.geolocation 请求用户的地理位置,但我收到了错误:
“https://www.googleapis.com/”的网络位置提供程序:已返回 错误代码 400。
此错误发生在 Chrome 54.0.2840.98 上。这在 Firefox 50.0 上没有问题。我正在使用http-server 运行本地服务器
函数如下:
_getLocation: function() {
if (!navigator.geolocation) {
alert('Geolocation is not supported by this browser, maybe use a pop-up and ask user for zipcode?');
}
function success(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
this.setState({
location: {
latitude: latitude,
longitude: longitude
}
});
this._getWeather(this.state.location.latitude, this.state.location.longitude);
}
function error(err) {
console.warn('ERROR(' + err.code + '): ' + err.message);
this.setState({
location: 'ERROR(' + err.code + '): ' + err.message
});
}
navigator.geolocation.getCurrentPosition(success.bind(this), error.bind(this));
},
【问题讨论】:
-
我也间歇性地遇到这个问题。