Google Geocode API的回调函数返回NULL值

时间:2016-10-10 12:07:51

标签: javascript google-maps

我有geoCode函数,它使用回调函数在异步请求完成后执行某些操作。但是,它返回NULL值。

 function codeAddress(callback) {

    /***** build string address from form data
    var address = addressOne + "," + addressTwo + "," + region + "," + zip + "," + country;
    *****/

    var geocodeAddress = geocoder.geocode( { 'address': address}, function (results, status) { callback( results ) } );

}

codeAddress(function(returnData){
    console.log("results= " + returnData);
    console.log(returnData);
     });

这给出了空数组

1 个答案:

答案 0 :(得分:0)

var returnData = function () {
         return data;
};

codeAddress (returnData ());

应该能够通过你喜欢的。