View source: R/query_rendered_features.R
get_queried_features | R Documentation |
This function retrieves the results of a feature query triggered by query_rendered_features()
.
It returns the features as a deduplicated sf object. Note that only features that were
visible in the viewport at the time of the query will be included.
get_queried_features(map)
map |
A map object (mapboxgl, maplibre) or proxy object (mapboxgl_proxy, maplibre_proxy, mapboxgl_compare_proxy, maplibre_compare_proxy) |
An sf object containing the queried features, or an empty sf object if no features were found
## Not run:
# In a Shiny server function:
observeEvent(input$query_button, {
proxy <- maplibre_proxy("map")
query_rendered_features(proxy, layer_id = "counties")
features <- get_queried_features(proxy)
print(nrow(features))
})
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.