0

I want to change the background color of my leaflet map:

My map:

    leaflet(data = mapa) %>%
   setView(lng = -50, lat = -15, zoom = 4) %>%
  addPolygons(fillColor = ~colorNumeric(palette = "YlGn", domain = mapa$n)(n),
              fillOpacity = 0.8,
              color = "#BDBDBD",
              weight = 1,
              highlight = highlightOptions(
                weight = 2,
                color = "#666",
                fillOpacity = 0.7,
                bringToFront = TRUE),
              label = ~paste0(UF, ": ", n),
              popup = paste0("UF: ", mapa$UF,
                           "<br>Parlamentares: ", mapa$parlamentares,
                           "<br>Partidos: ", mapa$partidos))
  • the easiest way to alter CSS to reflect the changes you wish to see. Here is an example of how someone resolved this issue with markers. https://stackoverflow.com/questions/33634901/leaflet-for-r-how-to-change-default-css-cluster-classes The idea is the same for background color, you just have to find it in the codebase Here is a link to the Github repo location for that CSS. https://github.com/rstudio/leaflet/blob/main/docs/styles.css You should be able to use one of the two methods in that stack posting to get you there! – sconfluentus Feb 24 '23 at 21:19
  • also, this specifically about background css: https://stackoverflow.com/questions/51869394/how-can-i-set-leaflet-map-background-to-be-white – sconfluentus Feb 24 '23 at 21:20

0 Answers0