enable_shiny_hover | R Documentation |
This function enables hover functionality for maplibre and mapboxgl widgets
in Shiny applications, providing _hover
and _feature_hover
input values.
enable_shiny_hover(map, coordinates = TRUE, features = TRUE)
map |
A maplibre or mapboxgl widget object. |
coordinates |
Logical. If TRUE, provides general mouse coordinates via |
features |
Logical. If TRUE, provides feature information via |
The modified map object with hover events enabled.
## Not run:
library(shiny)
library(mapgl)
ui <- fluidPage(
maplibreOutput("map"),
verbatimTextOutput("hover_info")
)
server <- function(input, output) {
output$map <- renderMaplibre({
maplibre() |>
enable_shiny_hover()
})
output$hover_info <- renderText({
paste("Mouse at:", input$map_hover$lng, input$map_hover$lat)
})
}
shinyApp(ui, server)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.