Using the RStudio Leaflet package in a shiny app I\'ve been able to achieve all the functionality I\'ve looked for except deselecting a marker object once it has been clicke
You could use a reactiveValues to store the clicked marker and reset it whenever the user clicks on the map background:
server <- shinyServer(function(input, output) {
data <- reactiveValues(clickedMarker=NULL)
# produce the basic leaflet map with single marker
output$map <- renderLeaflet(
leaflet() %>%
addProviderTiles("CartoDB.Positron") %>%
addCircleMarkers(lat = 54.406486, lng = -2.925284)
)
# observe the marker click info and print to console when it is changed.
observeEvent(input$map_marker_click,{
data$clickedMarker <- input$map_marker_click
print(data$clickedMarker)}
)
observeEvent(input$map_click,{
data$clickedMarker <- NULL
print(data$clickedMarker)})
})