setup_leaflet_observers
creates two observers for handling Leaflet map interactions in a linked component system.
The first observer handles direct marker clicks on the map, while the second observer
responds to selection changes from other linked components.
setup_leaflet_observers(
component_id,
session,
components,
shared_state,
on_selection_change,
registry = NULL
)
List containing two observer objects:
Handles marker click events on the map
Responds to selection changes from other components
Character string. The unique identifier for the Leaflet component.
'shiny' session object for the current user session.
List containing component configuration data including data reactives and shared ID columns.
Reactive values object containing selected_id and selection_source for coordinating selections across components.
Function to call when selection changes (currently unused).
Optional registry object with set_selection method for managing selections. If NULL, falls back to direct shared_state updates.
The marker click observer:
Extracts clicked marker ID from the click event
Retrieves corresponding data row from the component's data
Clears existing popups and applies click behavior (custom or default)
Updates selection state through registry or direct shared_state modification
The selection response observer:
Only responds to selections from other components (not self-selections)
Updates the map visualization to reflect the new selection