return result
mezoo opened this issue Β· comments
mezoo commented
Hi,
I don't understand how make result function, I m trying to do this π
var result;
gm.distance(from,to,function(err,data){
result = data;
});
console.log(result);
Output : undefined
It is possible to return result directly
Colin Kennedy commented
Try:
var result;
gm.distance(from,to,function(err,data){
result = data;
console.log(result);
});
No, it's not possible to return the result directly (with the current api). It makes an asynchronous call to the google maps api.
You could probably use something like: http://alexeypetrushin.github.io/synchronize/docs/index.html
To transform the call into a synchronous one, if that's what you're really after (but I imagine it's not).