var location
var point = new google.maps.LatLng(data[key].latitude, data[key].longitude);
var geocoder = new google.maps.Geocoder();
geocoder.geocode({
latLng: point
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[0]) {
location = results[0].formatted_address;
}
}
});
console.log(location);
when i console variable location
is undefined outside of geocode
function
here location
is undefined.
inside geocode
i am getting location value.