【问题标题】:Geolocation - Network location provider at 'https://www.googleapis.com/' : Returned error code 400地理位置 - 'https://www.googleapis.com/' 上的网络位置提供商:返回错误代码 400
【发布时间】: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));
  },

【问题讨论】:

  • 我也间歇性地遇到这个问题。

标签: google-chrome geolocation


【解决方案1】:

我不知道答案,但我注意到了... 我在 Visual Studio Code 的命令提示符下使用 http-server -o 来运行它,当它出现在 Google Chrome 中时我会收到此错误,但是,如果我将 url 'http://127.0.0.1:8082/' 复制到剪贴板并关闭初始Chrome 浏览器,从我的桌面打开一个全新的实例,然后粘贴 url 就可以了!

关于那个“新鲜”会话的某些东西按照我的意图正确使用了我的设置(允许任何网站跟踪我的位置),但通过 VSC 启动的另一种方式并没有......仍在调查......

【讨论】:

  • 同样的问题,你有进展吗?感谢分享
猜你喜欢
  • 2014-11-01
  • 1970-01-01
  • 2011-10-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多