[英]google api not working for geolocation
i have found a script for geolocation resolve with google in this code there is a key that is 86 char long 我在此代码中找到了一个与Google一起解析的地理定位脚本,该密钥长86个字符
i have opened a google api key for the gmail of the website it is a short key (only 39 chars) 我已经为网站的gmail打开了一个google api密钥,这是一个短键(仅39个字符)
i then changed the key and run the code. 然后,我更改了密钥并运行了代码。
i get the resolve country location that i need. 我得到了我需要的解决国家/地区位置。 i then tried from another ip location (at home) and one with a proxy sever and didn't get any thing
然后,我尝试从另一个IP位置(在家)和一个具有代理服务器的IP地址尝试,但没有得到任何东西
i'm not sure if the api key i'm using is set for public or not- how do i check that? 我不确定我使用的api密钥是否设置为公共-我该如何检查? do i have to pay for using it or can be used only with the free 25,000 request per day?
我需要付费使用还是只能每天免费使用25,000个请求?
the code i have tried is: 我尝试过的代码是:
<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.