I have attempted to create a leaflet map of the birthplaces of NHL players. However, I would like to add a title and/or a description in the map. I have attempted the addLegend argument and addControl but cant get a useful description. Below is the code I have used for the map.
pal <- colorFactor(palette = c("red", "blue", "green", "yellow", "black"),
levels = c("G", "D", "C", "LW", "RW"))
m <- map %>%
addCircleMarkers(data = players, radius = 1, popup = ~fullname,
color = ~pal(players$nationality),
label = paste0(players$fullname, "(", players$nationality, ")"))
m4 <- leaflet() %>%
addTiles(group = "OSM") %>%
addProviderTiles("Stamen.Terrain", group = "Stamen") %>%
addProviderTiles("CartoDB", group = "CartoDB") %>%
addCircleMarkers(data = goalies, radius = 1, label = ~htmlEscape(fullname),
color = ~pal(primaryposition), group = "G") %>%
addCircleMarkers(data = defense, radius = 1, label = ~htmlEscape(fullname),
color = ~pal(primaryposition), group = "D")%>%
addCircleMarkers(data = centers, radius = 1, label = ~htmlEscape(fullname),
color = ~pal(primaryposition), group = "C")%>%
addCircleMarkers(data = rightwings, radius = 1, label = ~htmlEscape(fullname),
color = ~pal(primaryposition), group = "RW")%>%
addCircleMarkers(data = leftwings, radius = 1, label = ~htmlEscape(fullname),
color = ~pal(primaryposition), group = "LW")%>%
addLayersControl(baseGroups = c("OSM", "Stamen.Terrain", "CartoDB"),
overlayGroups = c("G", "D", "C", "LW", "RW")) %>%
setView(lat = 39.8282, lng = -98.5795, zoom = 2)
m4
Any tips?
dput(df)
?