我通過navigator.geolocation
請求用戶的地理位置,但我越來越拋出的錯誤:地理位置 - 在「https://www.googleapis.com/」網絡位置提供:返回錯誤代碼400
Network location provider at ' https://www.googleapis.com/ ' : Returned error code 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));
},
我也可以間歇性地解決這個問題。 – stueynet