저는 지오 코더를 사용하여 우편 번호를 기반으로 위치를 얻고 있습니다 (미국에만 국한 됨). 유효하지 않은 우편 번호 (예 : 90123)를 입력하면 ZERO_RESULTS
대신 기본값으로 제공됩니다. 기본값은 텍사스 주 덴튼입니다 (모든 잘못된 코드의 경우). 이 문제를 방지하려면 어떻게해야합니까? 아니면이 문제를 피하기 위해 코드가 유효하지 않은지 여부를 말해주십시오.GeoCoder는 잘못된 우편 번호에 대한 기본값을 제공합니다.
geocoder.geocode({ 'address': zip, componentRestrictions: {country: 'us'} }, function (results, status) {
if (status == google.maps.GeocoderStatus.ZERO_RESULTS) {
jQuery('#zipErrorId').html("INVALID");
}
if (status == google.maps.GeocoderStatus.OK) {
geocoder.geocode({'latLng': results[0].geometry.location}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
var cityState = getCityState(results);
// like Apple Valley, Minnesota
var cityStateArr = cityState.split('|');
---------------------------
}
}
});
}