다음 코드는 비동기 적으로 작동합니다. 나는 도시, 국가를 위도와 경도로 변환하도록 설정했을뿐입니다. 그런 다음 그 값이 경고됩니다.Google의 GeoCode Convert City, STATE 위도 경도로
어떻게 실제로이 값을 반환하는 함수를 작성할 수 있습니까?
var map;
var geocoder;
function initialize() {
geocoder = new GClientGeocoder();
}
// addAddressToMap() is called when the geocoder returns an
// answer. It adds a marker to the map with an open info window
// showing the nicely formatted version of the address and the country code.
function addAddressToMap(response) {
//map.clearOverlays();
if (!response || response.Status.code != 200) {
alert("Sorry, we were unable to geocode that address");
} else {
place = response.Placemark[0];
latitude = place.Point.coordinates[0];
longitude = place.Point.coordinates[1];
alert("Latitude " + latitude + " Longitude" + longitude);
}
}
function showLocation(address) {
geocoder.getLocations(address, addAddressToMap);
}
정확히 내가 먼저 시도한 것이지만 양식 제출시 완료되고 시간 값이 설정되지 않습니다. – pws5068