住所コンポーネントを分割しようとしていますか?
通り、都市、州、郵便番号など....
その場合は...ジオコードされた結果を見て、返された住所の種類の配列を解析する必要があります。
使用できる簡単なサンプルコードを次に示します...
//Startup a new geocode instance
var geocoder = new google.maps.Geocoder();
//event.latLng is a latLng object passed into the geocode function to get
your addy results
geocoder.geocode({'location': event.latLng}, function(results, status) {
//Show the results here
console.log(results);
if (status == google.maps.GeocoderStatus.OK) {
var addressResults = results[0].address_components;
var address1 = "";
var address2 = "";
var city = "";
var state = "";
var zipCode = "";
for(var i = 0; i < addressResults.length; i++){
for(var j = 0; j < addressResults[i].types.length; j++){
if(addressResults[i].types[j] == 'street_number'){
address1 = addressResults[i].long_name;
break;
}
if(addressResults[i].types[j] == 'route'){
address1 += " " + addressResults[i].long_name;
break;
}
if(addressResults[i].types[j] == 'subpremise'){
address2 = addressResults[i].long_name;
break;
}
if(addressResults[i].types[j] == 'locality'){
city = addressResults[i].long_name;
break;
}
if(addressResults[i].types[j] == 'administrative_area_level_1'){
state = addressResults[i].short_name;
break;
}
if(addressResults[i].types[j] == 'postal_code'){
zipCode = addressResults[i].long_name;
break;
}
}
}
//Do ajax post to your form here with the data you just parsed out
}
});