add_cluster_button {webmap}R Documentation

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")

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".

Value

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

Author(s)

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

See Also

make_map function for creating a map widget.

Examples

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")

[Package webmap version 1.1.0 Index]