我使用google.loader.ClientLocation做了一些测试,这些测试来自:
但是我在测试中得到了null:
if (google.loader.ClientLocation)
这就是谷歌找不到知识产权信息时的行为。
我搜索了StackOverflow,有很多关于它的问题,但没有好的答案。
我在网上搜索了一下,发现了这两个链接:
这似乎表明应该使用导航器HTML地理位置。
Google API文档不再提及它。
我想确认一下 google.loader.clientlocation是否还在工作?
我的代码如下:
<html>
<head>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
</head>
<body>
<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>
</body>
</html>
发布于 2013-01-10 01:59:45
这个API看起来有点“过时”了,尽管它仍然适用于一些IP。
这是我从这里得到的答案:
加载器中的地理定位功能本身并没有停用。我们在几年前就停止了对它的记录,并推荐了基于HTML的解决方案,因为它们提高了准确性,但功能本身目前还没有从Loader中删除。谢谢!
因此,当找不到IP的位置时,google.loader.ClientLocation为null
https://stackoverflow.com/questions/14195837
复制相似问题