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.
Asked
Active
Viewed 1,055 times
1 Answers
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
-
Awesome! This might be stretching my luck but any way to change the font size of the title? – Ajjit Narayanan Nov 27 '18 at 22:13
-
I edited the answer. Change the number in `font-size:22px` to adjust the size of the text. Bonus: You can change the color as well :) – G. Cocca Nov 29 '18 at 08:53