r-spatial / mapview

Interactive viewing of spatial data in R
https://r-spatial.github.io/mapview/
GNU General Public License v3.0
516 stars 91 forks source link

Toggle legends to show/hide with layers #450

Closed Newtonrific closed 5 months ago

Newtonrific commented 1 year ago

With a map with multiple layers, but only one layer set to be visible on initiation (i.e. all other layers use hide = TRUE) the legends for all layers are shown on initiation. If a layer is then toggled to be visible then hidden again the legend also becomes hidden with the layer. Is it possible to have the legends for hidden layers also hidden on initiation?

jhagenauer commented 6 months ago

Same issue here. I would love if this could be fixed.

tim-salabim commented 5 months ago

Sorry for the long silence on this. It should work as expected now. Feel free to reopen if it doesn't.

tim-salabim commented 5 months ago
library(mapview)

m1 = mapview(franconia, zcol = "district", hide = TRUE)
m2 = mapview(breweries, zcol = "founded", hide = FALSE)
m3 = mapview(franconia, zcol = "SHAPE_AREA", hide = TRUE)

m12 = m1 + m2
m12

m123 = m12 + m3
m123