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.
Arguments
- component_id
Character string. The ID of the Leaflet map component to update.
- selected_id
Character string or NULL. The ID of the selected item. If NULL, indicates deselection.
- session
Shiny session object. The current Shiny session.
- components
List. A named list containing component information, where each element contains component configuration including data_reactive, shared_id_column, and config settings.
Details
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 featureslng_col
: Column containing longitude coordinateslat_col
: Column containing latitude coordinates