GeoCodingの呼び出しに都市のみを渡して、郵便番号を返さないと述べた場合。なぜですか?
これが私の電話です:
var test = 'New York, NY';
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': test }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var lat = results[0].geometry.location.lat();
var lng = results[0].geometry.location.lng();
var result=results[0].address_components;
//console.log(result);
var postal = null;
var city = null;
var state = null;
var country = null;
for(var i=0;i<result.length;++i){
if(result[i].types[0]=="postal_code"){
postal = result[i].long_name;
}
if(result[i].types[0]=="administrative_area_level_1"){
state = result[i].long_name;
}
if(result[i].types[0]=="locality"){
city = result[i].long_name;
}
if(result[i].types[0]=="country"){
country = result[i].long_name;
}
}
alert("POSTAL: " + postal);
alert("STATE: " + state);
alert("CITY: " + city);
alert("COUNTRY: " + country);
}