Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shiny Leaflet - hiding/removing legend

I have a R shiny-app which shows election results on a map using javascript library leaflet.

Initially, the map fill is based on winning party (a categorical variable). The user can switch too see the demographics (a continuous variable). I am able to get both the maps. But when leafletproxy is changing fill property of maps as requested by user, the legend of the previous map is not overwritten and instead the new legend comes on top of the previous legend. How can I remove legends in leaflet in R?

like image 591
ProgSnob Avatar asked Feb 13 '17 08:02

ProgSnob


1 Answers

I use..

leafletProxy("map") %>%
clearControls()

Before re-plotting and adding back in the legend.

like image 66
LuckySeedling Avatar answered Nov 08 '22 18:11

LuckySeedling