Click an event on a tile tile map in Shiny

Is it possible to get long long from a click event in a leaflet / shiny (in R) from a tile map? (i.e. NOT from any loaded markers, polygons, etc.). Just to show positional (lat / long) information, I think.

I thought maybe from this qu it was possible, but no luck.

ui <- bootstrapPage(
  tags$style(type = "text/css", "html, body {width:100%;height:100%}"),
  leafletOutput("map", width = "100%", height = "100%")
)

server <- function(input, output,session) {

  output$map <- renderLeaflet({
    leaflet() %>% 
      addProviderTiles("CartoDB.Positron")%>%
      setView(lng = -4, lat= 52.54, zoom = 7)
  })

  #Show popup on click
  observeEvent(input$map_marker_click, {
    click <- input$map_marker_click
    text<-paste("Lattitude ", click$lat, "Longtitude ", click$lng)

    proxy <- leafletProxy("map")
    proxy %>% clearPopups() %>%
      addPopups(click$lng, click$lat, text)
  })

}

runApp(shinyApp(ui, server), launch.browser = TRUE)

Ultimately, I want to create a click marker for the raster data (using the returned lat / long) in the Leaflet and Shiny, but that would be a good start (T its qu seemed to do something , but I can't recreate it at all) .

+4
source share

Source: https://habr.com/ru/post/1671028/


All Articles