title: close other infowindows nicely
body: <p>Im currently doing this to create markers for my google map.</p>
  
  <pre><code>function createMarker(posn, title, html) {
              var marker = new google.maps.Marker({ position: posn, title: title, draggable: false });
              marker['infowindow'] = new google.maps.InfoWindow({ content: html });
  
              infoWindows.push(marker['infowindow']);
              google.maps.event.addListener(marker, "click", function () {
                  for (i = 0; i &lt; infoWindows.length; i++) {
                      infoWindows[i].close();
                  }
                  this['infowindow'].open(map, this);
              });
              return marker;
          }
  </code></pre>
  
  <p>im not happy with the for loop, for closing the markers, i know something similar to this can be done by using one refernce:</p>
  
  <p>if (infowindow) infowindow.close();</p>
  
  <p>the reason I am using code like above is because i am doing something like<br>
    <code>markers[myPoint]['infowindow'].open(map, markers[myPoint]);</code> else where, (myPoint is a number).</p>
  
  <p>how can i avoid this for loop to close open infowindows and do it the nice way?</p>