(Untested) something like this:
function mk_handleImagePropertiesAsync(ival) {
return function(prop) {
settings.values["geoLat" + ival] = prop.latitude;
settings.values["geoLon" + ival] = prop.longitude;
settings.values["geoDate" + ival] = prop.dateTaken;
}
}
for (var i = 0; i < picsGiven.length; i++) {
picsGiven[i]
.properties
.getImagePropertiesAsync()
.then(mk_handleImagePropertiesAsync(i));
}
Scoping issue! The for-loop does not introduce a new block-scope as in C/C++. The inline function in your loop will always get the same value of i2 (its initial value!)