0
我想找到使用該LAT琅值我使用新google.maps地址。地理編碼器()。地理編碼() 下面是該方法
function checkAddress(){
var address="";
var amstr = new google.maps.LatLng(37.556179,-122.288219);
address = getAddress(amstr);
alert(address);
}
function getAddress(latLng) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode({'latLng': latLng},
function(results, status) {
if(status == google.maps.GeocoderStatus.OK) {
if(results[0]) {
return results[0].formatted_address;
}
else {
return "No results";
}
}
else {
return "not working";
}
});
}
但之後的實施運行上面的代碼我得到'未定義'的結果。 請告訴我我在哪裏做錯了。
謝謝
歡迎** **異步的奇妙世界!你不能那樣做。 – SLaks
然後應該做些什麼來獲得lat-lng的地址 – swapnil
使用回調。 – SLaks