0

I am using a shape file in leaflet plot & would like to have white color space external to the outer boundary of polygon shape instead of default greyish color background like color but unable to do so.

enter image description here

tried with: leaflet(options = leafletOptions(style = list("background-color" = "white")))

complete code:

ind_states %>% leaflet(options = leafletOptions(zoomControl = FALSE,
                                                dragging = FALSE,
                                                minZoom = 3,
                                                style = list(
                                                  "background-color" = "white"
                                                )
                                                )) %>%
          
          addPolygons(
                      label = label_daily,
                      labelOptions = labelOptions(
                        opacity = .6,
                        style = list(
                            "color" = "white",
                            "background-color" = "black",
                            "font-size" = "15px",
                            "border-color" = "rgba(0,0,0,0.5)"
                        )
                      ),
                      stroke = TRUE,
                      color = "white",
                      dashArray = "3",
                      weight = .2,
                      smoothFactor = .5,
                      opacity = 1,
                      fillOpacity = 0.5,
                      fillColor = ~ pal_daily(Daily_confirmed),
                      highlightOptions = highlightOptions(weight = .5,
                                                          fillOpacity = 1,
                                                          bringToFront = TRUE)) %>%

          addLegend(position = "bottomleft",
                    pal = pal_daily,
                    values = ~ ind_states$Daily_confirmed,
                    title = "Daily Confirmed Cases",
                    opacity = 0.7)

Also tried by adding: addTiles(fill = "white") %>% & addTiles(fillColor = "white") %>% but got error.

Desired result example with some random image: (choropleth map with external white space)

enter image description here

Would appreciate any help !!


UPDATE

from SO post: blank, white background for leaflet map

As per above link I saved my plot as R object: daily_leaflet_plt & ran below code but thats not working. I am not sure how to change css for this in rmarkdown

```{r results="daily_leaflet_plt"}
cat("
<style>
.leaflet-container {
    background: #FFF;
}
</style>
")
```
ViSa
  • 1,563
  • 8
  • 30
  • Have you tried stroke = TRUE & color = 'white' in addPolygons()? – Susan Switzer Aug 12 '21 at 17:49
  • 1
    @SusanSwitzer stroke & color = "white" is coloring the border into white whereas I am looking for external grey background space to be colored as white. – ViSa Aug 12 '21 at 17:54
  • As this issue is more relevant to css & it was answered in another SO post so closing this question: https://stackoverflow.com/questions/68767588/how-to-change-css-in-rmarkdown-cell-shiny/ – ViSa Aug 13 '21 at 07:14

0 Answers0