var i;
var marker = [];
var infowindow = [];
for(i=0; i<results.length ; i++ ){
marker[i] = new google.maps.Marker({
  position: results[i].geometry.location,
  map: map
});
infowindow[i] = new google.maps.InfoWindow({
  content: "test" + i
});
google.maps.event.addListener(marker[i], 'click', function(num) {
  return function() {
      infowindow[num].open(map, marker[num]);
  }
}(i)); 
}
I wrote some code to have different info window content when click on each marker (test1, test2, test3....) and the info window will remain on screen even i click another marker.
How to only show one infowindow when click on each marker?
 
    