0

在 google maps geocoder api 的第 2 版中,有一个方法 geocoder.getLocations 提供了很多有关请求地址的信息,例如:国家、街道、邮政编码、纬度、lng 等......

似乎该方法在 v3 中消失了,我们需要迭代 address_component

当我尝试这样做时,运行此程序时出现错误“未定义 j”

$.each(results[0].address_component, function (index, value) {
                        alert(index + ': ' + value);
                    });

http://maps.googleapis.com/maps/api/geocode/xml?address=75001,france&sensor=false

我如何迭代 adress_component 或更好的是如何到达 adress_component->输入国家/地区->短名称

谢谢

4

1 回答 1

0

我找到了如何迭代集合

$.each(results[0].address_components, function (index, value) {
                    $.each(value, function (index2, val) {
                        alert(index2 + ': ' + val);
                    });
                });

但是有没有更快的 jquery 方法来获取特定项目而无需迭代?我想到达'Country'类型的address_components我想现在是一个JQuery问题

于 2011-04-10T06:22:29.430 回答