add_search_button {webmap} | R Documentation |
Add search button to a web map
Description
Add a button to a Leaflet map to search markers/features location by property. Functionality provided by the leaflet-search plugin for Leaflet.
Usage
add_search_button(
map,
group,
property_name = "label",
zoom = NULL,
text_placeholder = "Search...",
open_popup = FALSE,
position = "topleft"
)
Arguments
map |
'leaflet'. Map widget object |
group |
'character' string. Name of the group whose features will be searched. |
property_name |
'character' string. Property name used to describe markers, such as, "label" and "popup". |
zoom |
'integer' count. Zoom level for move to location after marker found in search. |
text_placeholder |
'character' string. Message to show in search element. |
open_popup |
'logical' flag. Whether to open the marker popup associated with the searched for marker. |
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,
group = "marker",
data = us_cities
) |>
add_search_button(
group = "marker",
zoom = 15,
text_placeholder = "Search city names..."
)