From 59e28905ad4d5dd4e47f1d2bf85fffc51d8d5480 Mon Sep 17 00:00:00 2001 From: Millicool Date: Wed, 7 Jan 2026 20:20:07 +0100 Subject: [PATCH] Unselect map area by clicking it again --- server.R | 8 ++++++++ 1 file changed, 8 insertions(+) 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