I\'m completely puzzled here. I have a list of objects each containing a location. I look up this location using the google.maps.geocoder and afterwards I put a marker for that
Don't create closures in loops. That just won't work. This might be a solution for the problem:
function callback() {
return function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
addMarker(map, item, results[0].geometry.location);
} else {
console.log("Geocode failed " + status);
}
};
}
for (var item in list) {
var geocoder = new google.maps.Geocoder();
var geoOptions = {
address: item.location,
bounds: bounds,
region: "NO"
};
geocoder.geocode(geoOptions, callback());
}