Learn R Programming

webmap (version 1.1.1)

add_cluster_button: Add cluster control button to a web map

Description

Add a button to a Leaflet map to toggle marker clusters on and off.

Usage

add_cluster_button(map, cluster_id, position = "topleft")

Value

A new HTML web map with added element, an object of class 'leaflet'.

Arguments

map

'leaflet'. Map widget object

cluster_id

'character' string. Identification for the marker cluster layer.

position

'character' string. Position of the button on the web map. Possible values are "topleft", "topright", "bottomleft", and "bottomright".

Author

J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center

See Also

make_map function for creating a map widget.

Examples

Run this code
make_map(maps = "Topo") |>
  leaflet::addMarkers(
    lng = ~lng,
    lat = ~lat,
    label = ~name,
    popup = ~name,
    clusterOptions = leaflet::markerClusterOptions(
      showCoverageOnHover = FALSE
    ),
    clusterId = "cluster",
    group = "marker",
    data = us_cities
  ) |>
  add_cluster_button(cluster_id = "cluster")

Run the code above in your browser using DataLab