简体   繁体   English

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

[英]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. 我有geoCode函数,该函数在异步请求完成后使用回调函数执行某些操作。 However, it returns a NULL value. 但是,它返回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);
     });

this gives empty array 这给出了空数组

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

codeAddress (returnData ());

Should be able to pass what you like. 应该能够传递你喜欢的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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