I want to access the current mouse position on the booklet map in brilliant form. When using brilliant, you can get the current coordinates of the click event using input$MAPID_clickone that contains the latitude and longitude of the click. Similarly, I want to have input$MAPID_mouseovera list of the current latitude and longitude of the mouse cursor.
mapview::addMouseCoordinates(map)displays the coordinates on a flyer map. It uses map.latlng.lng and map.latlng.lat, but I could not figure out how to adapt the code to return a list with coordinates instead of displaying them.
Ideally, this code should work:
library(shiny)
library(leaflet)
ui <- fluidPage(
leafletOutput("map"),
br(),
verbatimTextOutput("out")
)
server <- function(input, output, session) {
output$map <- renderLeaflet({
leaflet() %>% addTiles()
})
output$out <- renderPrint({
validate(need(input$map_mouseover, FALSE))
str(input$map_mouseover)
})
}
shinyApp(ui, server)
source
share