update_leaflet_selection
updates a Leaflet map component to reflect a new selection state. This function
handles both selection and deselection events, applying either custom user-defined
click handlers or default behaviors.
update_leaflet_selection(component_id, selected_id, session, components)
NULL (invisibly). The function is called for its side effects on the Leaflet map.
Character string. The ID of the Leaflet map component to update.
Character string or NULL. The ID of the selected item. If NULL, indicates deselection.
'shiny' session object. The current 'shiny' session.
List. A named list containing component information, where each element contains component configuration including data_reactive, shared_id_column, and config settings.
The function performs the following operations:
Validates that the leaflet package is available
Checks that required columns (shared_id_column, lng_col, lat_col) exist in the data
Clears existing popups on the map
For selections: finds the selected data row and applies either custom click handler or default behavior
For deselections: delegates to custom handler or performs default cleanup
Required columns in the component data:
shared_id_column
: Column containing unique identifiers for map features
lng_col
: Column containing longitude coordinates
lat_col
: Column containing latitude coordinates