如何在R中的传单地图中的标记上接收鼠标单击事件?我正在使用RStudio /传单并通过Shiny运行.
我想获取标记的值(例如,ID)并使用它来更新sidebarPanel.
使用下面的示例,我试图找出一种向我闪亮的应用程序添加功能的方法,以便执行以下操作:
基本上我希望能够点击地图上的车站或用键盘手动输入车站。
这可以用传单吗?我已经看到使用 plotly 的参考资料,这可能是最终的解决方案,但如果可能的话,我很乐意在不小的部分发布传单,因为我已经对传单做了很多工作。尽管这里有工作示例,但这与此问题类似:
library(shiny)
library(leaflet)
library(shinydashboard)
library(ggplot2)
library(dplyr)
data("quakes")
shinyApp(
ui = dashboardPage(title = "Station Lookup",
dashboardHeader(title = "Test"),
dashboardSidebar(
sidebarMenu(
menuItem("Data Dashboard", tabName = "datavis", icon = icon("dashboard")),
menuItem("Select by station number", icon = icon("bar-chart-o"),
selectizeInput("stations", "Click on Station", choices = levels(factor(quakes$stations)), selected = 10, multiple = TRUE)
)
)
),
dashboardBody(
tabItems(
tabItem(tabName = "datavis",
h4("Map and Plot"),
fluidRow(box(width= 4, leafletOutput("map")),
box(width = 8, plotOutput("plot")))
)
)
)
), …Run Code Online (Sandbox Code Playgroud)