谷歌API不工作的地理位置

问题描述:

我发现在这个代码与谷歌 地理位置决心的脚本有是86字符长谷歌API不工作的地理位置

我已经打开了该网站 的Gmail的一个谷歌API密钥的密钥它是一个短键(只有39个字符)

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

我得到我需要的解析国家位置。 我然后尝试从另一个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> 
+0

如果你打开URL'http://www.google.com/jsapi ?key ='直接在你的浏览器中,第13行说的是什么? – YuS 2012-02-22 10:39:45

+0

in line 13 it says:null,but give me the location with the IP with i used when opened api for the email account – 2012-02-22 11:31:34

+0

您是否使用过笔记本电脑?它可能是一个缓存问题呢? – YuS 2012-02-22 16:25:36

好像地理位置是不可靠的 见菲利普的回答这里Is google.loader.clientlocation still supported