moshen / node-googlemaps

A simple way to query the Google Maps API from Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

return result

mezoo opened this issue Β· comments

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

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).