google.maps.event.addListener(marker, 'click', function(currentMarker, currentInfoWindow) { return function() { currentInfoWindow.open(map, currentMarker); } }(marker, infoWindow));