There is a easier way besides using the close() function. if you create a variable with the InfoWindow property it closes automatically when you open another.
var info_window; var map; var chicago = new google.maps.LatLng(33.84659, -84.35686); function initialize() { var mapOptions = { center: chicago, zoom: 14, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); info_window = new google.maps.InfoWindow({ content: 'loading' )}; createLocationOnMap('Location Name 1', new google.maps.LatLng(33.84659, -84.35686), '<p><strong>Location Name 1</strong><br/>Address 1</p>'); createLocationOnMap('Location Name 2', new google.maps.LatLng(33.84625, -84.36212), '<p><strong>Location Name 1</strong><br/>Address 2</p>'); } function createLocationOnMap(titulo, posicao, conteudo) { var m = new google.maps.Marker({ map: map, animation: google.maps.Animation.DROP, title: titulo, position: posicao, html: conteudo }); google.maps.event.addListener(m, 'click', function () { info_window.setContent(this.html); info_window.open(map, this); }); }