I have declared a local variable inside of getAddress.
When I try to access that variable inside a local function it falls outside its scope.
What am I doing wrong?
function getAddress(latlon, map)
{
var data = "";
$("#map-canvas").gmap3({
marker: {
latLng: latlon,
options:{
draggable:false,
},
},
getaddress:{
latLng: latlon,
callback: function(results){
data = results && results[1] ? results && results[1].formatted_address : "no address";
},
},
});
console.log(data); // Outputs empty string
}