我有这个功能:
function findAddressViaGoogle(address){
var geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': address }, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
return results[0].formatted_address;
} else {
console.log("Unable to find address: " + status);
}
});
}
如何打印此函数的返回值?
如果我做:
$('#location-suggest').text('Do you mean <a>'+findAddressViaGoogle($(this).val())+'</a> ?');
它打印未定义