简体   繁体   中英

callback function for Google Geocode API returning NULL Value

I have the geoCode function that uses a callback function to do something after the asynchronous request has completed. However, it returns a NULL value.

 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);
     });

this gives empty array

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

codeAddress (returnData ());

Should be able to pass what you like.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM