title: How to toggle between KML/KMZ layers in Google Maps api v3
body: <p>I'm developing a web page with a Google maps application. Currently, I have a functional search bar and map that displays three KML/KMZ layers. I need to be able to toggle between each of the layers, either display one of them, two of them or all three. There is a similar function in Google Earth, but I need it in Google Maps. How can I do this? </p>
  
  <p>Here is my code for the map and search bar: </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      var geocoder;
      var map; 
      var marker;
    function initialize() {
      geocoder = new google.maps.Geocoder ();
      var latlng = new google.maps.LatLng (40.43, -74.00);
      var myOptions = {
        zoom: 5,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
          }
        map = new google.maps.Map(document.getElementById("map_canvas"),
          myOptions);
        marker = new google.maps.Marker({map:map});
  
      var ctaLayer = new google.maps.KmlLayer('http://dl.dropbox.com/u/80233620/NY_Radar_data.kmz');
          ctaLayer.setMap(map);
      var ctaLayer = new google.maps.KmlLayer('http://www.nyc.gov/html/dot/downloads/misc/cityracks.kml');
          ctaLayer.setMap(map);
      var ctaLayer = new google.maps.KmlLayer('http://dl.dropbox.com/u/80233620/OKX_Radar_data%20(1).kmz');
          ctaLayer.setMap(map);
          }
      function codeAddress () {
          var address = document.getElementById ("address").value;
          geocoder.geocode ( { 'address': address}, function(results, status)  {
          if (status == google.maps.GeocoderStatus.OK)  {
              map.setCenter(results [0].geometry.location);
              marker.setPosition(results [0].geometry.location);
              map.setZoom(14);
              } 
          else {
              alert("Geocode was not successful for the following reason: " + status);
                  }
      }); 
                              }
  &lt;/script&gt;
  </code></pre>