title: Filtering leaflet markers in Meteor app
body: <p>I was to allow the user to show and hide markers in a Leaflet map by selecting the category from a list of checkboxes. </p>
  
  <pre><code>var createMarkers = function () {
  
      var markers = new L.LayerGroup({});
  
      Locations.find().forEach(function (location) {
          var lat, lng, category, popup
          lat = location.lat;
          lng = location.lng;
          category = location.category
  
          popup = "location.name + location.category;
  
          return markers.addLayer(new L.marker([lat, lng], {
            icon: icon
          }).bindPopup(popup));
  
          }
      })
  }
  
  
  Meteor.subscribe('locations', createMarkers);
  </code></pre>
  
  <p>I have a session that returns an array of categories based on the checkbox selection(s), but not sure the best way to then update the markers on the client based on this. </p>
  
  <p>I've also considered using the Leaflet.GroupedLayerControl plugin but not sure if that's a better, Meteor way to go.. </p>