Can someone help me with this?
The array always return blank.
var x = [];
geocoder.geocode('29 champs elysée paris', function(err, res) {
x.push(res)
});
console.log(x);
/* The result( res ) of the function is a Array....
Can someone help me with this?
The array always return blank.
var x = [];
geocoder.geocode('29 champs elysée paris', function(err, res) {
x.push(res)
});
console.log(x);
/* The result( res ) of the function is a Array....
geocoder.geocode()
runs asynchronously.
Is this more what you're looking for?
var x = [];
geocoder.geocode('29 champs elysée paris', function(err, res) {
x.push(res)
console.log(x);
});
If you need to examine the array after several different geocoder.geocode()
executions (or other asynchronous executions) you'd need some other infrastructure to handle that. Research asynchronous functions a bit to find examples on that.