I am encountering an issue where I cannot set a value inside a function. When I attempt to alert this value, it returns as undefined. How can I retrieve this value outside of the function?
var startingLatitude;
L.esri.Geocoding.geocode()
.text(document.getElementById('start').value)
.run(function (error, results, response) {
if (error) {
console.log(error);
return;
}
startingLatitude = results['results'][0].latlng.lat;
});
alert(startingLatitude);