title: Open only one infowindow at a time google maps
body: <p>Im trying to create a google map with multiple markers that allows only one info window at a time. The markers are the locations of IP cameras and they are fetched through ruby. I've read loads of answers to similar questions whereby the solution is to create only one info window and re-use it.</p>
  
  <p>I have tried to implement the solutions from a number of other questions but I can't get it to work.</p>
  
  <pre><code>  $(document).ready(function () {
  // execute
  (function () {
    // map options
    var options = {
      zoom: 2,
      center: new google.maps.LatLng(25, 10), // centered US
      mapTypeControl: false,
      streetViewControl: false
    };
  
    // init map
    var map = new google.maps.Map(document.getElementById('map-canvas'), options);
  
    // set multiple marker
    &lt;% @cameras.each do |c| %&gt;
    // init markers
      &lt;% if c.deep_fetch(:location) {} != nil %&gt;
  
    var marker = new google.maps.Marker({
      position: new google.maps.LatLng(&lt;%= c.deep_fetch(:location, :lat) {} %&gt;, &lt;%= c.deep_fetch(:location, :lng) {} %&gt;),
      map: map,
      title: 'Click Me '
    });
  
    // process multiple info windows
    (function (marker) {
      // add click event
      google.maps.event.addListener(marker, 'click', function () {
        infowindow = new google.maps.InfoWindow({
          content: "&lt;%= preview(c, true) %&gt;"+
              '&lt;h5&gt;&lt;%= c["name"] %&gt;&lt;/h5&gt;'+
              '&lt;p&gt;&lt;a href="/publiccam/&lt;%= c['id'] %&gt;"&gt;View Camera&lt;/a&gt;&lt;/p&gt;'
  
        });
  
        infowindow.open(map, marker, this);
      });
    })(marker);
    &lt;% end %&gt;
    &lt;% end %&gt;
  
  })();
  });
  </code></pre>
  
  <p>Is it possible to create just one info window due to the way I am creating an info window for each camera with &lt;% @cameras.each do |c| %>?</p>