I have this javascript function which geocodes a LatLng object:
function geolocate_table(location)
{
geocoder.geocode({'latLng': location}, function(results, status){
if( status == google.maps.GeocoderStatus.OK){
if(results[0])
{
console.log(results[0].formatted_address);
return(results[0].formatted_address);
}
else
return("Non disponibile");
}
else
{
return("jasand");
}
});
}
My problem is that if I call the function from another one (e.g.:
function test(latlng)
{
var street;
street=geolocate_table(latlng);
console.log(street);
}
The console log of test will give me "undefined" even if the original value in geolocate_table
is correctly evaluated and logged in the console.
Am i doing something wrong?
Thank you in advance for your answers :)