1. Learn
  2. /
  3. Courses
  4. /
  5. Interactive Maps with leaflet in R

Connected

Exercise

Swapping Popups for Labels

Popups are great, but they require a little extra effort. That is when labels come to our aid. Using the label argument in the addCircleMarkers() function we can get more information about one of our markers with a simple hover!

ipeds %>% 
    leaflet()  %>% 
    addProviderTiles("CartoDB")  %>% 
    addCircleMarkers(label = ~name, radius = 2)

Labels are especially helpful when mapping more than a few locations as they provide quick access to detail about what each marker represents.

Instructions 1/2

undefined XP
  • 1

    Add circle markers with labels identifying the name of each college to the current map.

  • 2

    Add sector information to the label inside parentheses.