下面的最小示例呈现具有 3 个市场的传单地图和具有 3 条记录的 DT 表。当地图上的一个市场被选中时,表格上的匹配记录也会被选中。但是,我不能做的是,也有相反的情况,表格上单击的行也会在地图上显示相关的弹出窗口。
我一直无法找到一个具有类似功能的示例 R 闪亮传单应用程序。
代码经过调整以反映最初的评论
library(shiny)
library(leaflet)
library(DT)
library(tidyverse)
# Define UI for application that draws a histogram
ui <- fluidPage(
leafletOutput("opsMap"),
DT::dataTableOutput('ranksDT')
)
# Define server logic required to draw a histogram
server <- function(input, output) {
lats <- c(21.608889,21.693056, 24.04)
longs <- c(-74.650833, -73.095,-74.341944)
popups <- c('a','b','c')
layerids <- c('a','b','c')
iconNames <- c('cog','cog','cog')
iconColors <- c('red','red','red')
sampleData <- tibble(lats,longs, popups,layerids,iconNames,iconColors)
score <- c(7,3,9)
locationRanks <- tibble(popups, score)
output$opsMap <- renderLeaflet({
leaflet() %>% …
Run Code Online (Sandbox Code Playgroud)