r-spatial / leafgl

R package for fast web gl rendering for leaflet
Other
263 stars 31 forks source link

addGlPolygons not rendering polygons but the outer edge of all the shape #68

Open paragemini opened 2 years ago

paragemini commented 2 years ago

Hello I have a shapefile of blocks geography of cook county and trying to plot them on leaflet map. When I cast multipolygons to to polygons using this command

leaflet() %>% 
  addProviderTiles(providers[[113]]) %>% 
  addGlPolygons(data = st_transform(st_cast(blocks_sf_f, "POLYGON"),
                                        crs = '+proj=longlat +datum=WGS84'),weight = 0.1,
                popup = "GEOID10")

I get the below map

image

when I select random rows then individual polygons are being loaded

leaflet() %>% 
  addProviderTiles(providers[[113]]) %>% 
  addGlPolygons(data = st_transform(st_cast(blocks_sf_f[c(1:10000),], "POLYGON"),
                                        crs = '+proj=longlat +datum=WGS84'),
                weight = "10px",
                color = "green",
                popup = "GEOID10", fillColor = "yellow")```

then the shapes are being loaded, though sequential but one can not see the border. Let me know if there is a workaround for it or not ? to show just the stroke using weight. I tried that option too but for reason the weight also does not do anything. ALso is therer any option for for fillcolor to be not anything, like addPolygons has fill = FALSE argument

image

tim-salabim commented 2 years ago

Hi @paragemini it is currently not possible to add a border via the addGlPolygons() call. As a workaround, you could add a addGlPolyLines() on top. That is what we currently do in mapview. This is currently in the pipline, but still needs some ironing. You could install the dev version from here and see if that solves your issue (I have enabled the border functionality, but as I said, it's still a bit buggy).

As for the fill to be transparent, you can set fillOpacity = 0.