title: HIDE/SHOW Markers
body: <p>I am developing a website that has a mapping and i am using leaflet. Now im on the part that i will hide /show markers that i made.</p>
  
  <p>below is my code finding the image that i want and use it as a marker</p>
  
  <pre><code>var Icon1 = L.icon({
      iconUrl: 'legends/fire.GIF',
       iconSize:     [170, 120], // size of the icon
      iconAnchor:   [100, 120], // point of the icon which will correspond to marker's location
      popupAnchor:  [-7, -80] // point from which the popup should open relative to the iconAnchor
  </code></pre>
  
  <p>the other one below is my code when putting the mark on the map.</p>
  
  <pre><code>function mark()
  {
  if (select1.value === "Fire"){
  var note = document.getElementById('note');
  var datepick = document.getElementById('demo1');
  var timepick = document.getElementById('timepick');
          map.on('click', function(e){
          var marker = new L.Marker(e.latlng,{icon: Icon1});
          marker.bindPopup("&lt;/a&gt;&lt;br&gt;&lt;strong&gt;FIRE&lt;/strong&gt;&lt;/br&gt;&lt;strong&gt;Date:&lt;/strong&gt;"+datepick.value+"&lt;/br&gt;&lt;strong&gt;Time:&lt;/strong&gt;"+timepick.value+"&lt;/br&gt;&lt;strong&gt;Address:&lt;/strong&gt;"+note.value+"&lt;strong&gt;&lt;br&gt;&lt;strong&gt;Suspect Sketch&lt;/strong&gt;&lt;br&gt;&lt;a href=legends/suspect.jpg rel=lightbox&gt;&lt;img src = legends/suspect.jpg height=100 width = 100/&gt;").addTo(map);
  
          marker.on('dragend');
          });
  </code></pre>
  
  <p>This is my code in hiding the marker.</p>
  
  <pre><code>script type="text/javascript"&gt;
  
  function closure(marker){
  var checkbox = document.getElementById("chbx")
  
     $(chbx).click(function(){
        if(map.hasLayer(marker)){
          window.alert("I want to hide the marker");
        }
        window.alert("I want to show the marker");
     })
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>This is just what i wanted.
  1.Add A marker on the map
  2.Hide/Show the marker in the map
  3.Make this happen during run time or when i try it.</p>
  
  <p>I try everything but still nothing happens.
  What is the right thing to do to call my hide/show function in checkbox?</p>