diff --git a/server.R b/server.R index 139f3f4..b57ca2d 100644 --- a/server.R +++ b/server.R @@ -96,6 +96,14 @@ server <- function(input, output, session) { click_event <- input$hhmap_shape_click # Check if an ID was returned (meaning a polygon was clicked) if (!is.null(click_event$id)) { + if(click_event$group == "selected") { + # Clicked on an already selected area of the map therefore we unselect. + currently_selected_bezirk("") + currently_selected_stadtteil("") + leafletProxy("hhmap") %>% + clearGroup("selected") + return() + } # The ID of the clicked polygon clicked_polygon_id <- click_event$id