Chrome navigator.geolocation.getCurrentPosition() 错误403
Chrome navigator.geolocation.getCurrentPosition() error 403
由于某种原因,在调用 navigator.geolocation.getCurrentPosition()
时突然出现此错误:
Network location provider at 'https://www.googleapis.com/' : Returned error code 403.
昨天它曾经完美运行!他们的服务器会不会有什么问题??
发生这种情况
我怀疑这与为 Deprecating Powerful Features on Insecure Origins it seems that some changes were done in the last few days in this chromium Issue 520765: Deprecation and removal of powerful features on insecure origins
计划的更改 google 有关
您能否通过 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);
})
看来它现在已经恢复了。但在我意识到它正在工作之前,我使用了另一种方法来获取位置数据,这是 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/
我遇到了同样的问题,您必须检查您的 developer dashboard 并确保您的 API 密钥没有使用限制或警告。
由于某种原因,在调用 navigator.geolocation.getCurrentPosition()
时突然出现此错误:
Network location provider at 'https://www.googleapis.com/' : Returned error code 403.
昨天它曾经完美运行!他们的服务器会不会有什么问题??
我怀疑这与为 Deprecating Powerful Features on Insecure Origins it seems that some changes were done in the last few days in this chromium Issue 520765: Deprecation and removal of powerful features on insecure origins
计划的更改 google 有关您能否通过 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);
})
看来它现在已经恢复了。但在我意识到它正在工作之前,我使用了另一种方法来获取位置数据,这是 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/
我遇到了同样的问题,您必须检查您的 developer dashboard 并确保您的 API 密钥没有使用限制或警告。