使用Google Maps API进行反向地理编码 [英] Reverse geocoding with Google Maps API

查看:176
本文介绍了使用Google Maps API进行反向地理编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了用于反向地理编码的代码:

I have found this code for reverse geocoding:

var point = new GLatLng (lat[1],long[1]);
var geocoder = new GClientGeocoder();
geocoder.getLocations (point, function(result) { alert (lat[1]+' '+long[1]+' '+result.address); });

但是它弹出警报,说result.address是'undefined'.有什么想法,可能是什么问题?

But it pops the alert, saying that result.address is 'undefined'. Any ideas, what could be the problem?

编辑:该工具正常运行,谢谢.

Got it working, thanks.

推荐答案

可以包含"lat"和"long"的定义吗?另外,"long"是保留关键字,因此很可能是拼写错误/错误.

can you include the definitions of 'lat' and 'long'? also, 'long' is a reserved keyword, so that is likely a typo / bug.

此外,返回的结果(至少以gmaps v2 json格式)具有更复杂的结构,并且'result.address'将不具有任何内容.当我对其进行测试时,我需要使用以下内容访问其中一个地址:

also, the results that come back, at least in gmaps v2 json format, have a more complex structure, and 'result.address' won't have anything. when I tested it out, I needed to access one of the addresses with something like:

result.Placemark[0].address

请参见 http://code.google.com/apis/maps/documentation/geocoding/index.html#GeocodingResponses

这篇关于使用Google Maps API进行反向地理编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆