Search code examples
r-leaflet

How to only allow one layergroup activated Leaflet R?


I have made a leaflet map in R, which works perfectly fine. But I would like that only one overlay group can be activated at a time, so when you click another overlay group, the first one is removed. So in the example below that it is not possible to have "Socialdemokratiet" and "Konservative" activated at the same time, so instead when I activate one of them the other is deactivated. How do I do that?

enter image description here


Solution

  • Instead of using the overlayGroups argument in theaddLayersControl function, use baseGroups instead:

    addLayersControl(baseGroups=Groups)