I'm getting stuck on something that's probably pretty simple.
I can console.log a return value from the codeAddress function, but I can't get it to return to another function that calls it. The two lines in question are called out with comments.
Please don't mind my terrible XX concatenation; I'm just trying to figure out the function calls.
Any help would be greatly appreciated. Thanks!
function codeAddress(zipCode) {
geocoder.geocode( { 'address': zipCode}, function(results, status) {
var lat = results[0].geometry.location.d;
var lng = results[0].geometry.location.e;
var latlng = lat+'XX'+lng;
return latlng; // I can console log this value
});
}
var citymap = {};
function loadMap() {
$.ajax({
url: 'getdata.php',
data: "query=geolocate",
dataType: 'json',
success: function (zips) {
for (var i in zips)
{
var entry = zips[i];
citymap[entry['zip_code']]= {
scans: entry['num_scans'],
position: codeAddress(entry['zip_code']) // But it will never return down here
};
}
}
});
}