Skip to contents

This helper function provides consistent default behavior for leaflet maps when handling selection events. It manages popup display and map navigation based on the selection state.

Usage

apply_default_leaflet_behavior(map_proxy, selected_data, component_info)

Arguments

map_proxy

A leaflet map proxy object used to update the map

selected_data

A data frame or list containing the selected row/item data. If NULL, indicates deselection occurred.

component_info

A list containing component configuration information:

shared_id_column

Character. Name of the column containing unique identifiers

config

List containing:

lng_col

Character. Name of the longitude column

lat_col

Character. Name of the latitude column

highlight_zoom

Numeric. Zoom level to use when highlighting selection

Value

Returns the modified map proxy object with updated view and popups

Details

When selected_data is provided:

  • Creates a popup with "Selected" header and ID information

  • Sets map view to the selected location coordinates

  • Applies the configured highlight zoom level

When selected_data is NULL (deselection):

  • Removes all existing popups from the map

Examples

if (FALSE) { # \dontrun{
# Apply default behavior when item is selected
apply_default_leaflet_behavior(map_proxy, selected_row, component_info)

# Apply default behavior when item is deselected
apply_default_leaflet_behavior(map_proxy, NULL, component_info)
} # }