LoslegenKostenlos loslegen

Putting it all Together

Let's try putting this all together at one time. Building our interactive map of every four-year college in America can be broken down into four steps:

  1. Initialize the web map
  2. Lay down our base maps
  3. Plot each sector of colleges as its own layer
  4. Add layer controls so users can toggle base and overlay groups

The public, private, and profit data frames as well as the color palette pal have been loaded for you.

Diese Übung ist Teil des Kurses

Interactive Maps with leaflet in R

Kurs anzeigen

Anleitung zur Übung

  • Fill in the function names to create an interactive web map that has multiple overlay and base map groups.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

m4 <- ___() %>% 
        ___(group = "OSM") %>% 
        ___("CartoDB", group = "Carto") %>% 
        ___("Esri", group = "Esri") %>% 
        ___(data = public, radius = 2, label = ~htmlEscape(name),
                         color = ~pal(sector_label),  group = "Public") %>% 
        ___(data = private, radius = 2, label = ~htmlEscape(name),
                           color = ~pal(sector_label), group = "Private")  %>% 
        ___(data = profit, radius = 2, label = ~htmlEscape(name),
                         color = ~pal(sector_label), group = "For-Profit")  %>% 
        ___(baseGroups = c("OSM", "Carto", "Esri"), 
                         overlayGroups = c("Public", "Private", "For-Profit")) %>% 
        ___(lat = 39.8282, lng = -98.5795, zoom = 4) 

m4
Code bearbeiten und ausführen