title: how to hide google map markers by a button?
body: <p>I have a Google map. I created some markers, but I can not hide these markers. I looked at <a href="https://developers.google.com/maps/documentation/javascript/examples/marker-remove" rel="nofollow">this document</a>. I have one function, but it failed.</p>
  
  <pre><code>function LoadMap () {
    var markers = JSON.parse('&lt;%=Stations() %&gt;');
    var mapOptions = {
      center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
      zoom: 5,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var infoWindow = new google.maps.InfoWindow();
    map2 = new google.maps.Map(document.getElementById("map_canvas2"), mapOptions2);
    for (i = 0; i &lt; markers.length; i++) {
      var data = markers[i]
      var myLatlng = new google.maps.LatLng(data.lat, data.lng);
      var marker = new google.maps.Marker({
        position: myLatlng,
        map: map2,
        title:"Hello",
      });
      (function (marker, data) {
        google.maps.event.addListener(marker, "click", function (e) {
          infoWindow.setContent(data.description);
          infoWindow.open(map, marker);
          icon: InitIcon
        });
      }(marker, data);
    }
  }
  </code></pre>