Skip to contents

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.

Usage

update_leaflet_selection(component_id, selected_id, session, components)

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.

Value

NULL (invisibly). The function is called for its side effects on the Leaflet map.

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 features

  • lng_col: Column containing longitude coordinates

  • lat_col: Column containing latitude coordinates

Note

If the leaflet package is not available, the function returns early without error. Missing required columns will generate a warning and cause early return.