How to create an event when you click on the flyer popup in R?

I would like to make the tabPanel change to Shiny when I click on the Leaflet polygon. I have a couple of ideas on how to do this, but I can’t find the information needed to implement them. I have a leaf in tabPanel, but I would like to switch to another tab when a polygon is clicked on it.

    leaflet(llmap) %>%
      addTiles() %>%
      addPolygons(stroke = F,
                  fillOpacity = .8,
                  smoothFactor = .5,
                  color=~pal(x),
                  popup = pop)

I was thinking of creating popup=updateTabsetPanel(session="New Tab"), but that doesn't work. My other idea is to call updateTabsetPanel(session="New Tab")at any time when the user clicks on the new polygon, but I don’t know what event I will need to return in order to tell him that the new polygon was pressed or even if a pop-up window pops up. Does anyone know this?

+3
1

, :

output$myMap <- renderLeaflet({
    map_out() #this is just a function that returns a leaflet map
  })


output$MyGraph <- renderPlot({  
    event <- input$myMap_shape_click #Critical Line!!!

    ... #Code to run here

    GraphData <- GraphData[event$id] # subsetting example

    }
  })  

, :

  • input$myMap_shape_click , . myMap, . output$YourMap , input$YourMap_shape_click

  • , , event$id. + , . event$lat event$lng

  • renderPlot . , observe, . , , . , input$myMap_shape_click , .

updateTabsetPanel, , :

observe({

  event <- input$myMap_shape_click

  updateTabsetPanel(session, "inTabset", selected = event$id)

}) 

, .

+8

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


All Articles