r-spatial / leafgl

R package for fast web gl rendering for leaflet
https://r-spatial.github.io/leafgl/
Other
266 stars 32 forks source link

addGlPolygons fillColor does not work #62

Closed jhsuss closed 3 years ago

jhsuss commented 3 years ago

Hello - I've been trying to use leafgl::addGlPolygons to render a large dataset of polygons, but the fill does not seem to be working. Here is example adapted from ?addGlPolygons:

gadm = st_as_sf(gadmCHE) gadm = st_cast(gadm, "POLYGON") cols = grey.colors(nrow(gadm)) cols_fill = topo.colors(nrow(gadm)) leaflet() %>% addProviderTiles(provider = providers$CartoDB.DarkMatter) %>% addGlPolygons(data = gadm, color = cols, fillColor =cols, popup = TRUE)

trafficonese commented 3 years ago

You are using cols as color and fillColor. If you use cols_fill instead you will see colored polygons.

jhsuss commented 3 years ago

Sorry that was a typo! The issue is that it doesn't work when fillColor = cols_fill

trafficonese commented 3 years ago

I am getting a colored polygon set with this code:

leaflet() %>%
  addGlPolygons(data = gadm, color = cols, fillColor = cols_fill, popup = TRUE)

I think color is not used and only fillColor is applied, as polygon borders are currently not supported.

jhsuss commented 3 years ago

Sorry, I see what the issue was -- I hadn't been viewing in browser!