[R] Adding multiple polygons to a Leaflet map
Kevin Haynes
khaynes17 at gmail.com
Tue Aug 30 18:26:56 CEST 2016
Hi everyone - I'd like to add multiple polygons to a leaflet map. I don't
get any errors when running this code, but it'll only display the second
choro layer - the citizenship rate one. Here's my code below. Any thoughts?
Here's the map right now:http://rpubs.com/khaynes17/205217
#map
la_trad_school_perf_map_layers <- leaflet(lac_schools) %>%
addProviderTiles("CartoDB.Positron") %>%
setView(-118.4, 34.05, zoom = 9) %>%
addCircleMarkers(
radius = 3,
color = ~pal(metandabove_mth),
stroke= FALSE, fillOpacity = 0.5,
group="14-15 Proficiency Rates - Math"
) %>%
addPolygons(data = income_merged,
fillColor = ~pal_income(MedianIncome_2014),
color = "#b2aeae",
fillOpacity = 0.5,
weight = 1,
smoothFactor = 0.2,
popup = popup_income,
group="Median Income - 2014")%>%
addPolygons(data = cit_merged,
fillColor = ~pal_cit(non_citizenship_rate),
color = "#b2aeae",
fillOpacity = 0.5,
weight = 1,
smoothFactor = 0.2,
popup = popup_cit,
group="Non-U.S. Citizen - 2014")%>%
addLayersControl(
baseGroups=c("Median Income - 2014", "Non-U.S. Citizen - 2014"),
overlayGroups=c("14-15 Proficiency Rates - Math"),
options = layersControlOptions(collapsed = FALSE)
)
la_trad_school_perf_map_layers
[[alternative HTML version deleted]]
More information about the R-help
mailing list