Google지도 API를 사용하여 alpha2 코드로지도를 표시하는 앱이 있지만 In (인도)) 및 CA (캐나다).IN (인도) 및 CA (캐나다)에 대한 국가 alpha2 코드로 Google지도 API 지오 코드 오류
function codeAddress() {
var address = document.getElementById('address').value;
geocoder.geocode({ 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
위의 함수의 주소 변수가 국가의 전체 이름 (인도, 캐나다) 걸릴 수 있지만, 내 응용 프로그램은 알파 2 코드를 공급 : 코드는 다음입니다. 내 임시 해결책은 위의 함수에서 'IN'과 'CA'라는 하드 코드이지만, 더 나은 전략이 있는지 궁금합니다.