function fillInAddress() {
var place = autocomplete.getPlace();
var geocoder = new google.maps.Geocoder();
var latitude;
var longitude;
geocoder.geocode({ 'address': place.formatted_address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
latitude = results[0].geometry.location.lat();
longitude = results[0].geometry.location.lng();
} else {
alert("Request failed.")
}
});
document.getElementById("long").value = longitude;
document.getElementById("lat").value = latitude;
}
我无法访问geocode()函数之外的纬度和经度。请帮忙。