Я обертываю вызов геокодера в функцию, передаю ваш объект в эту функцию, затем вы можете использовать его и в обратном вызове геокодера.
пример:
// i'm just staging a fake for loop here...
for(var i = 0; i < 10; i++){
// this is your basic object
var obj = {address: "Brussels Belgium"};
// here you call the geo function and pass the object so that you can access it inside the function
doGeoCode(obj);
}
function doGeoCode(obj) {
// your geocoder wrapped in a function, takes 1 argument which you can reference in the callback below
var geocoder;
geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': obj.address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var p = results[0].geometry.location;
// inside this callback function you can just reference 'obj'
obj.position = {'longitude': p.lng(), 'latitude': p.lat()};
} else {
// your mexican thingy
}
});
}