地理位置 - 在“https://www.googleapis.com/”网络位置提供:返回错误代码400

问题描述:

我通过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)); 
    }, 
+0

我也可以间歇性地解决这个问题。 – stueynet

我不知道答案,但我注意到这... 我使用HTTP服务器-o在命令提示符在Visual Studio Code中运行它,当它出现在谷歌浏览器中时出现此错误,但是,如果我将网址'http://127.0.0.1:8082/'复制到剪贴板并关闭了初始Chrome浏览器,则从我的桌面上打开一个全新的实例,然后粘贴在它工作正常的网址!

一些事“新鲜”的会话使用我的设置(允许任何网站跟踪我的位置)正确,因为我打算而是通过VSC推出的其他方式不...仍在调查......

+0

同样的问题在这里,你有没有取得任何进展?感谢分享 – troig