0

Is there any way to add a 'blank' legend with just a title to a leaflet map using the R leaflet pacakge? I was hoping to mimic a map title using a blank legend.

Ajjit Narayanan
  • 632
  • 2
  • 8
  • 18

1 Answers1

2

You can use addControl() argument to add a legend and pass an html paragraph tags$p i.e. a string of text (here in bold, tags$b)

library(leaflet)
library(htmltools)

my_title <- tags$p(tags$style("p {color: red; font-size:22px}"),
            tags$b("My_beautiful_title_goes here"))


my_map <- leaflet() %>%
addTiles() %>%
setView(10.533, 45.822, zoom = 11) %>%
addControl(my_title, position = "bottomright" )

my_map
G. Cocca
  • 2,456
  • 1
  • 12
  • 13