![](/img/trans.png)
[英]Google Maps API v3 Geolocation not working in Google Chrome
[英]google api not working for geolocation
我在此代码中找到了一个与Google一起解析的地理定位脚本,该密钥长86个字符
我已经为网站的gmail打开了一个google api密钥,这是一个短键(仅39个字符)
然后,我更改了密钥并运行了代码。
我得到了我需要的解决国家/地区位置。 然后,我尝试从另一个IP位置(在家)和一个具有代理服务器的IP地址尝试,但没有得到任何东西
我不确定我使用的api密钥是否设置为公共-我该如何检查? 我需要付费使用还是只能每天免费使用25,000个请求?
我尝试过的代码是:
<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的答案这里是否仍然支持google.loader.clientlocation
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.