title: How to add a scale bar in the R package leaflet?
body: <p>I have recently discovered the r package “leaflet” and found a great blog with some basic instruction for creating an interactive map (found here) <a href="http://mhermans.net/hiking-gpx-r-leaflet.html" rel="noreferrer">http://mhermans.net/hiking-gpx-r-leaflet.html</a>. </p>
  
  <p>I have not, however been successful at adding a scale bar on the map. That is, I’d like to add a graphic feature that scales distance as you zoom in and out of the map (e.g. a bar at the bottom of the map that represents 1km). The leaflet site (found here) <a href="http://leafletjs.com/reference.html#control-scale-l.control.scale" rel="noreferrer">http://leafletjs.com/reference.html#control-scale-l.control.scale</a> discusses this feature: L.control,scale(). </p>
  
  <p>Does anyone know how to add a scale bar??</p>
  
  <p>This is the code for my map so far (The “Add Scale Bar” Does NOT work): </p>
  
  <pre><code># A map of Track data
  Mymap &lt;- leaflet() %&gt;% addTiles() %&gt;% 
    addPolylines(data=Dofu1) %&gt;% 
    addPolylines(data=Zak1) %&gt;% 
    addProviderTiles("Esri.WorldImagery")   
  
  # Add a legend 
    Mymap %&gt;% 
      addLegend(position = 'topright', 
                colors = "blue", 
                labels = 'Buruku Tracks', opacity = 0.5,
                title = '')
  
    # Add a Scale Bar 
    Mymap %&gt;% 
      addControl(Mymap, "Scale", 
              position = c("topright"), 
              layerID = NULL, 
              className = "Scale", 
              data - getMapData(Mymap))
  </code></pre>