谷歌api不适用于地理定位

google api not working for geolocation

本文关键字:定位 适用于 api 不适用 谷歌      更新时间:2023-09-26

我在谷歌上找到了一个地理位置解析脚本在这个代码中有一个密钥是86个字符长的

我已经为该网站的gmail打开了一个googleapi密钥这是一个短密钥(只有39个字符)

然后我更改了密钥并运行代码。

我得到了我需要的决心所在的国家。然后我尝试从另一个ip位置(在家里)和一个有代理服务器的位置,但没有得到任何东西

我不确定我使用的api密钥是否设置为public-我该如何检查?我必须为使用它付费吗?还是只能在每天25000次免费请求的情况下使用?

我尝试过的代码是:

<script type="text/javascript" src="http://www.google.com/jsapi?key="></script>
<script type="text/javascript"> 
function geoTest() {
    if (google.loader.ClientLocation) {
        var latitude = google.loader.ClientLocation.latitude;
        var longitude = google.loader.ClientLocation.longitude;
        var city = google.loader.ClientLocation.address.city;
        var country = google.loader.ClientLocation.address.country;
        var country_code = google.loader.ClientLocation.address.country_code;
        var region = google.loader.ClientLocation.address.region;
        var text = 'Your Location<br /><br />Latitude: ' + latitude + '<br />Longitude: ' + longitude + '<br />City: ' + city + '<br />Country: ' + country + '<br />Country Code: ' + country_code + '<br />Region: ' + region;
    } else {
        var text = 'Google was not able to detect your location';
    }
    document.write(text);
}
geoTest();
</script>

似乎地理位置不可靠请点击此处查看Philippe的答案谷歌下载客户端位置是否仍然支持