title: How to add a marker with a specific class to a layer or layergroup?
body: <p>I have a couple of markers that have a css class with its names, for example: markerOne has .markerone as css class, and so on.
  Its possible to create a function to assign these markers to specific layers or groups? Something like <code>var layerone = $(L.marker).hasClass("markerone"));</code> and assign all markers with that class inside a layer?
  I want to do this so later I can toggle that layer on/off with addLayer and removeLayer.</p>
  
  <p>Function that I use to show the markers:</p>
  
  <pre><code>function showResourcesByName(name) {
              for (var i = 0; i &lt; markers.resources.length; i++) {
                  var resName = markers.resources[i].name;
  
                  if (resName == name) {
                      var resIcon = icons.resources[i].icon;
                      var resSize = icons.resources[i].size;
                      var resPname = icons.resources[i].pname;
  
                      var customIcon = L.icon({
                          iconUrl: resIcon,
                          iconSize: resSize, // size of the icon
                          iconAnchor:   [resSize[0]/2, resSize[1]/2], // point of the icon which will correspond to marker's location
                          popupAnchor:  [2, -resSize[1]/2] // point from which the popup should open relative to the iconAnchor
                      });
  
                      for (var j = 0; j &lt; markers.resources[i].coords.length; j++) {
                          var x = markers.resources[i].coords[j].x;
                          var y = markers.resources[i].coords[j].y;
  
                          marker = L.marker([y, x], {icon: customIcon});
                          marker.addTo(map).bindPopup(resPname);
                          $(marker._icon).addClass(name)
  
  
  
                      }
                  }
              }
          }
  </code></pre>
  
  <p>The class that I mention is the (name) part in $(marker._icon).addClass(name), which grabs the name from markers.js:</p>
  
  <pre><code>    var markers = {
    "resources": [
      {
        "name": "AITokarServer",
        "coords": [
          {
            "x": -1210.0,
            "y": -1770.0
          },
          {
            "x": -1230.0,
            "y": -1810.0
          },
  </code></pre>
  
  <p>So all markers with the name AITokarServer will have a class .AITokarServer and so on.</p>