是否有人可以給我解釋以下行爲:谷歌的地理編碼阿比
function getLatLong()
{
var geocoder = new google.maps.Geocoder();
var result = "";
geocoder.geocode ({ 'address': "London", 'region': 'uk' }, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
result = results[0].geometry.location;
alert('Im called second');
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
alert('Im called first');
return result;
}
怎樣第二警報消息被稱爲第一警報之前?我有一個問題,我試圖返回賦值變量'result'的值,但它仍然作爲空字符串返回,即使它從result [0] .geometry.location中分配了一個值。我有一種可怕的感覺,我錯過了一些非常明顯的東西:/
完美。非常感謝您的明確解釋! – BIOS 2012-08-13 22:51:49