我要做的就是找出这个人的 IP 地址,这样我就可以对其进行反向地理编码,以找出他们查看我网站的纬度和经度。
我可以使用 Google ClientLocation API但我不清楚我是否必须加载巨大的谷歌地图框架才能使用它。
是否可以简单地使用 ClientLocation API 而无需加载所有 Google map ?如果是这样,怎么做?
最佳答案
是的,您只需要使用 google.loader 命名空间中的 ClientLocation 对象,因此您无需引用 map api 或其他任何东西。例如。
<script src="http://www.google.com/jsapi" language="javascript"></script>
<script language="javascript">
if (google.loader.ClientLocation != null) {
alert(google.loader.ClientLocation.address.city);
} else {
alert("Not found");
}
</script>
可用的属性是
关于google-maps - 如何在不加载整个 Google Maps API 的情况下加载 Google ClientLocation API?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3233767/