15

How can I make the background of the Leaflet map transparent. I see opacity controls from the layers, but not the map background. Should the be changed just with plain CSS?

3 Answers 3

20

Hey plain CSS did the trick:

.leaflet-container {
    background-color:rgba(255,0,0,0.0);
}
1

This worked for me,

.leaflet-container {
  background: none !important;
}
-2

Try using the leaflet.extras package -- you can make the background white or transparent!

library(leaflet.extras)

mapname%>%

setMapWidgetStyle(list(background= "white"))
3
  • This question is about Javascript Leaflet. Commented Jan 16, 2019 at 18:37
  • @Jessie this is for leaflet on Javascript not R
    – csheth
    Commented Apr 9, 2020 at 7:24
  • I found this very useful, because I couldn't find an appropriate answer for R. Came up on google, problem solved. Thank you.
    – Stephan
    Commented Feb 18, 2021 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.