所以我有
function find_coord(lat, lng) {
var smart_loc;
var latlng = new google.maps.LatLng(lat, lng);
geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'latLng': latlng }, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
smart_loc = new smart_loc_obj(results);
} else {
smart_loc = null;
}
});
return smart_loc;
}
我想返回 smart_loc 变量/对象,但它始终为 null,因为函数的范围(结果,状态)没有达到 find_coord 函数中声明的 smart_loc。那么如何获取函数内部的变量(结果、状态)呢?