Function to toggle the watersheds layer on an existing leaflet map.

ff_layer_watersheds(
  m,
  show = TRUE,
  selected_return = NULL,
  selected_group = NULL
)

Arguments

m

An initialized leaflet map object or leafletProxy object.

show

A boolean value indicating whether the function call will be adding the layer to the map (TRUE) or removing the layer from the map (FALSE). Designed to be changed via shiny checkbox input by calling the function inside an observer.

selected_return

The return_id of a return point to filter to, if desired.

selected_group

The group_id of a watershed to filter to, if desired.

Examples

# show the layer on a leaflet map object ("m")
m <- ff_make_leaflet()
m |> ff_layer_watersheds(show = TRUE)
# hide the layer on a leaflet map object ("m") m |> ff_layer_watersheds(show = FALSE)
# use as part of a Shiny app with map "mainMap" and a boolean selector "show_canals" if(FALSE){ shiny::observe({ proxy <- leaflet::leafletProxy("mainMap") proxy |> ff_layer_watersheds(show = input$show_watersheds) }) }