My code
// do ajax request and get JSON response
for (var i = 0; i < data.results.length; i++) { result = data.results[i]; // do stuff and c
The classic closure problem strikes again!
google.maps.event.addListener(marker, 'click', function(id) { return function(){ createWindow(id); //<==== this doesn't work because marker always points to the last results when this function is called } }(marker.id));