A Legendary Map
Adding information to our map using color is great, but it is only helpful if we remember what the colors represent. With addLegend() we can add a legend to remind us.
There are several arguments we can use to custom the legend to our liking, including opacity, title, and position. To create a legend for our colorNumeric() example, we would do the following.
pal <- colorNumeric(palette = "RdBu", domain = c(25:50))
ipeds %>%
leaflet() %>%
addProviderTiles("CartoDB") %>%
addCircleMarkers(radius = 2,
color = ~pal(lat)) %>%
addLegend(pal = pal,
values = c(25:50),
opacity = 0.75,
title = "Latitude",
position = "topleft")
यह अभ्यास पाठ्यक्रम का हिस्सा है
Interactive Maps with leaflet in R
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Add a legend that displays the colors used in pal
m %>%
___(pal = pal,
values = c("Public", "Private", "For-Profit"))