title: onclick hide/show google map marker
body: <p>I'm going to have several markers (right now I'm just doing two until I get the structure going) and I'd like to be able to click on external links that open the marker's info box, but when one marker's info box is open the other gets closed.  I'd also like to be able to hide and show the markers.  So when one button is pushed it hides the first marker, and when the other button is pushed it shows the first one and hides the second.  </p>
  
  <p>Right now I have my map set up like this and am unsure where to go from here with how to toggle the visibility setting and the info bubbles.</p>
  
  <pre><code>var LOC_850 = new google.maps.LatLng(42.326435,-71.149499);
  
  
  var mapOptions = {
    zoom: 16,
    center: LOC_850,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
  
  
  var CONTENT_850 = '&lt;div id="content"&gt;'+
      '&lt;div id="siteNotice"&gt;'+
      '&lt;/div&gt;'+
      '&lt;h1 id="firstHeading" class="firstHeading"&gt;Uluru&lt;/h1&gt;'+
      '&lt;div id="bodyContent"&gt;'+
      '&lt;p&gt;&lt;b&gt;Uluru&lt;/b&gt;, also referred to as &lt;b&gt;Ayers Rock&lt;/b&gt;, is a large ' +
      'sandstone rock formation in the southern part of the '+
      'Northern Territory, central Australia. It lies 335&amp;#160;km (208&amp;#160;mi) '+
      'south west of the nearest large town, Alice Springs; 450&amp;#160;km '+
      'Heritage Site.&lt;/p&gt;'+
      '&lt;/div&gt;';
  
  var INFO_850 = new google.maps.InfoWindow({
      content: CONTENT_850
  });
  var BTN_850 = 'CONTAINER_850';
  var MARKER_850 = new google.maps.Marker({
      position: LOC_850,
      map: map,
      title: 'Hello World!'
  });
  google.maps.event.addListener(MARKER_850, 'click', function() {
    INFO_850.open(map,MARKER_850);
  });
  google.maps.event.addDomListener(document.getElementById(BTN_850), 'click', function() {
    INFO_850.open(map,MARKER_850);
  });
  
  
  
  
  
  var LOC_850_60bus_out = new google.maps.LatLng(42.326822,-71.150157);
  var CONTENT_850_60bus_out = '&lt;div id="content"&gt;'+
      '&lt;div id="siteNotice"&gt;'+
      '&lt;/div&gt;'+
      '&lt;h1 id="firstHeading" class="firstHeading"&gt;DIFFERENT&lt;/h1&gt;'+
      '&lt;div id="bodyContent"&gt;'+
      '&lt;p&gt;&lt;b&gt;Uluru&lt;/b&gt;, also referred to as &lt;b&gt;Ayers Rock&lt;/b&gt;, is a large ' +
      'sandstone rock formation in the southern part of the '+
      'Northern Territory, central Australia. It lies 335&amp;#160;km (208&amp;#160;mi) '+
      'south west of the nearest large town, Alice Springs; 450&amp;#160;km '+
      'Heritage Site.&lt;/p&gt;'+
      '&lt;/div&gt;';
  
  var INFO_850_60bus_out = new google.maps.InfoWindow({
      content: CONTENT_850_60bus_out
  });
  var BTN_850_60bus_out = 'CONTAINER_850_60bus_out';
  var MARKER_850_60bus_out = new google.maps.Marker({
      position: LOC_850_60bus_out,
      map: map,
      title: 'Hello World!'
  });
  google.maps.event.addListener(MARKER_850_60bus_out, 'click', function() {
    INFO_850_60bus_out.open(map,MARKER_850_60bus_out);
  });
  google.maps.event.addDomListener(document.getElementById(BTN_850_60bus_out), 'click', 
  function() {
    INFO_850_60bus_out.open(map,MARKER_850_60bus_out);
  });
  
  }
  
  
  function loadScript() {
  var script = document.createElement('script');
  script.type = 'text/javascript';
  script.src = 'https://maps.googleapis.com/maps/api/js?sensor=false&amp;' +
      'callback=initialize';
  document.body.appendChild(script);
  }
  
  window.onload = loadScript;
  &lt;/script&gt;
  </code></pre>