[R] Adding multiple polygons to a Leaflet map

Adams, Jean jvadams at usgs.gov
Thu Sep 1 22:41:37 CEST 2016


It is hard to troubleshoot without the data.  Can you provide the data, for
example using the dput() function, or can you replicate the issue with some
simplified version of code that we can run?

Jean

On Tue, Aug 30, 2016 at 11:26 AM, Kevin Haynes <khaynes17 at gmail.com> wrote:

> 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]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list