Chrome navigator.geolocation.getCurrentPosition()错误403

时间:2015-09-01 10:36:14

标签: google-maps google-chrome navigator google-geolocation

出于某种原因突然调用navigator.geolocation.getCurrentPosition()时出现此错误:

Network location provider at 'https://www.googleapis.com/' : Returned error code 403.

昨天以前工作得很好!他们的服务器可以有任何东西吗?

4 个答案:

答案 0 :(得分:14)

现在看来已经恢复了。但在我意识到它工作之前,我使用另一种方法来获取reddit.com上其他用户推荐的位置数据

var latLong;
$.getJSON("http://ipinfo.io", function(ipinfo){
    console.log("Found location ["+ipinfo.loc+"] by ipinfo.io");
    latLong = ipinfo.loc.split(",");
});

来源:https://www.reddit.com/r/webdev/comments/3j8ipj/anyone_else_had_issues_with_the_html5_geolocation/

答案 1 :(得分:6)

这不是HTTPS的事情,即使谷歌自己的示例失败,请参阅https://developers.google.com/maps/documentation/javascript/examples/map-geolocation

我在reddit上打开了一个帖子并找到更多内容并在此处链接:https://www.reddit.com/r/webdev/comments/3j8ipj/anyone_else_had_issues_with_the_html5_geolocation/

我让世界各地的人报告同样的问题。

答案 2 :(得分:1)

idoco.github.io/map-chat

也发生了这种情况

我怀疑这与谷歌为Deprecating Powerful Features on Insecure Origins计划的变化有关。似乎在过去几天内已经对此铬进行了一些更改Issue 520765: Deprecation and removal of powerful features on insecure origins

您可以通过https测试您的网站以确认吗?

同时我发现这个api用法是this repo的一种解决方法:

  $.getJSON("http://ipinfo.io", function(doc){
    var latlong = doc.loc.split(",")
    setUserLocation(parseFloat(latlong[0]), parseFloat(latlong[1]));
    getLocation(parseFloat(latlong[0]), parseFloat(latlong[1])).then(function(res){
      userLocationName = res
    })
    initialiseEventBus();
    map.panTo(userLocation);

  }, function(err) {
    setUserLocation(Math.random()*50, Math.random()*60);
    userLocationName = "unknown.na"
    initialiseEventBus();
    map.panTo(userLocation);
  })

答案 3 :(得分:0)

我遇到了同样的问题,您必须检查developer dashboard并确保您的API密钥没有使用限制或警告。