Skip to content
This repository was archived by the owner on Sep 30, 2021. It is now read-only.
This repository was archived by the owner on Sep 30, 2021. It is now read-only.

How to add colorNumeric, auto-scaling fillColor to polygons #19

@e-leo

Description

@e-leo

Hello,
I am new to using your package and I'm attempting to replicate something I would do in the base leaflet (1 below) which is to make a color gradient based on a continuous variable. Code chunk 2 is how far I've gotten. I attempted to just use the same syntax as I had done in base leaflet, but it returned "Wasn't able to determine range of domain" when I just used the name of the variable in quotes and when I tried to wrap it in the JS() function.

1:
pal <- colorNumeric(palette = "YlGnBu", domain = joined$uninsured) popup <- paste0("Area: ", joined$NAMELSAD10, "<br>", "Uninsured: ", joined$uninsured) leaflet() %>% addProviderTiles("CartoDB.Positron") %>% addPolygons(data=joined, fillColor = ~pal(uninsured), color = "#b2aeae", fillOpacity = 0.7, weight = 1, smoothFactor = 0.2, popup = popup) %>% addLegend(pal = pal, values = joined$uninsured, position = "bottomright", title = "Uninsured by PUMA")

2:
leaflet() %>% #addProviderTiles(providers$Esri.WorldTopoMap) %>% setView(-76, 39, 7) %>% addEsriBasemapLayer(esriBasemapLayers$Gray, autoLabels = TRUE) %>% addEsriFeatureLayer(url = "https://services.arcgis.com/njFNhDsUCentVYJW/ArcGIS/rest/services/Pandemic_Unemployment_Assistance_Claims/FeatureServer/1", useServiceSymbology = FALSE, labelProperty = "ZIPCODE1", popupProperty = JS(paste0( "function(feature) {", " return L.Util.template(", " \"<h3>{ZIPCODE1}</h3><hr />", " <p> PUA Claims: {Claims} </p>", " \",", " feature.properties", " );", "}")), options = featureLayerOptions(renderer = ) )%>% addLegend(pal = pal, values = log10("Claims"), position = "bottomright", title = "PUA Claims by ZIP code")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions