A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://gis.stackexchange.com/questions/491944/increasing-font-of-scalebar-in-leaflet-r below:

Increasing font of scaleBar in Leaflet R

I would like to increase the font of my scale bar located on the topright side. I am a proficient R user but don't know much about JavaScript. I couldn't find an option to increase the font in addScaleBar() so I hope it can be done with JavaScript. Example below:

UPDATE: According to this webpage https://runebook.dev/en/articles/leaflet/index/control-scale-getcontainer ,the scale bar can be modified. The htmltools R package has a function call onRender() to handle javaScript code in R, however, I am trying to learn about that function right now. Code below:

    map <- leaflet() %>%
  addTiles() %>%
  setView(lng = -121.2722, lat = 38.1341, zoom = 10)  

# Add a scale bar to the map
map <- map %>%
  addScaleBar() %>% 
onRender("
 L.Control.MyCustomScale = L.Control.Scale.extend({
  onAdd: function(map) {
    var container = this._initLayout();

    // Create your custom scale UI here (HTML elements, styles, etc.)

    this._map = map;
    return container;
  },

  // Override other methods as needed to customize behavior
});

var customScaleControl = new L.Control.MyCustomScale({position: 'topleft', font-size: '20px'});
customScaleControl.addTo(map);
")  
map

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4