SymbolixAU / mapdeck

R interface to Deck.gl and Mapbox
https://symbolixau.github.io/mapdeck/articles/mapdeck.html
362 stars 40 forks source link

Click-event circular references #391

Open dcooley opened 1 month ago

dcooley commented 1 month ago

https://github.com/SymbolixAU/mapdeck/issues/364 is now happening with click-events

library(shinydashboard)
library(mapdeck)
library(sf)
set_token(secret::get_secret("MAPBOX"))

ui <- shinydashboard::dashboardPage(
    header = shinydashboard::dashboardHeader()
    , body = shinydashboard::dashboardBody(
        mapdeck::mapdeckOutput(
            outputId = "map"
        )
    )
    , sidebar = shinydashboard::dashboardSidebar()
)

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

    nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"))

    output$map <- mapdeck::renderMapdeck({

        mapdeck::mapdeck() %>%
            add_polygon(
                data = nc       
            )
    })

    observeEvent({input$map_polygon_click}, {
        print(input$map_polygon_click)
    })

}

shiny::shinyApp(ui = ui, server = server)