title: Find out if a leaflet control has already been added to the map
body: <p>I wrote a custom Leaflet control. It's some kind of legend that may be added for each layer. The control itself has a close button to remove it from the map (like a popup). 
  The control can be added by clicking a button.
  My problem is that the user may add the same control to the map several times. So what I need is to test if this specific control has already been added to the map and, if so, don't add it again.</p>
  
  <p>I create a control for each layer, passing some options</p>
  
  <pre><code>var control = L.control.customControl(mylayer);
  </code></pre>
  
  <p>and add it to my map on button click</p>
  
  <pre><code>control.addTo(map);
  </code></pre>
  
  <p>Now imagine the control has a close button and may be closed. Now if the user clicks the button again, I only want to add the control if it's not already on the map - something like this (hasControl is pseudocode, there is afaik no such function)</p>
  
  <pre><code>if(!(map.hasControl(control))) {
      control.addTo(map);
  }
  </code></pre>
  
  <p>For simplicity I made an example where I create a zoom control and add it twice <a href="http://jsfiddle.net/Krxldfx/y8mevuum/2/">here</a>.</p>