Overlay Groups

Interactive Maps with leaflet in R

Rich Majerus

Vice President of Strategy & Planning, Queens University of Charlotte

Grouping Colleges by Sector

m <- ca_colleges %>% 
  leaflet() %>% 
  addProviderTiles("CartoDB") 
m %>% 
  addCircleMarkers(
              radius = 2,
              label = ~name)

CA college layers 1

ca_public <- ipeds  %>% 
  filter(sector == "Public", 
         state == "CA") 
m %>% 
  addCircleMarkers(
        data = ca_public,
        group = "Public")

CA college layers 2

Interactive Maps with leaflet in R
m %>% 
 addCircleMarkers(
   data = ca_public,
   color = ~pal(sector_label),
   group = "Public")  %>% 

addCircleMarkers( data = ca_private, color = ~pal(sector_label), group = "Private") %>%
addCircleMarkers( data = ca_profit, color = ~pal(sector_label), group = "For-Profit")

CA college layers 1

Interactive Maps with leaflet in R
m %>% 
 addCircleMarkers(
   data = ca_public,
   color = ~pal(sector_label),
   group = "Public")  %>% 

addCircleMarkers( data = ca_private, color = ~pal(sector_label), group = "Private") %>%
addCircleMarkers( data = ca_profit, color = ~pal(sector_label), group = "For-Profit") %>%
addLayersControl( overlayGroups = c("Public", "Private", "For-Profit"))

  CA college layers 3

Interactive Maps with leaflet in R

What We are Working Toward

All college layers

Interactive Maps with leaflet in R

Let's practice!

Interactive Maps with leaflet in R

Preparing Video For Download...