なぜこれが機能しないのですか?googlemapapiから返されたアドレスコンポーネントをループできません。
if (geocoder) {
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var arrAddress = results[0].address_components;
console.log(arrAddress);
//iterate through address_component array
$.each(arrAddress, function (i, address_component) {
console.log('address_component:'+i);
if (address_component.types[0] == "locality"){
console.log("town:"+address_component.long_name);
}
});
}
}