2011-04-10 87 views
0

在谷歌地圖geocoder api的版本2中,有一種方法 geocoder.getLocations提供了很多有關請求地址的信息,例如:country,street,zip code ,緯度,經度,等...找不到谷歌地圖的國家代碼api 3地理編碼請求

好像方法是在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->型國家 - >短名

感謝

回答

0

我發現如何遍歷集合

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

但有沒有一種更快的jQuery方式來到達特定的物品而無需迭代? 我想到address_components類型'國家' 我想現在它是一個JQuery的問題