Leaflet Shiny - 活动地图标记点击 - 打开地块

时间:2016-10-06 09:39:57

标签: plot shiny leaflet

我有一个闪亮的应用程序,在地图上显示一些标记。当我点击一个标记时,我在右侧面板的表格中有一些信息。当我点击标记时,该表格对应于ID。

我的问题是:这有可能帮助我修改下面的代码,这样:我想在点击标记时显示一个情节,并且情节已经在某个地方完成,他的名字是" Graph_QJ&#34 ;.表格"我的数据"。

没有链接

代码使用表格,并进行修改以显示" Graph_QJ"当我点击一个标记时:

library(leaflet)
library(shiny)
library(shinydashboard)
library(plotly)













shinyUI=dashboardPage(

    # Header
    dashboardHeader(title = "Suivis Pit-Tag - Charriage",titleWidth = 450,
                    dropdownMenuOutput("messageMenu1"),
                    dropdownMenuOutput("messageMenu2"),
                    disable = FALSE),

    # Barre de menu
    dashboardSidebar(
      sidebarMenu(id="menu",menuItem("Les sites de mesures", tabName = "sites")
      )
    ), #end dashboard sidebar


    # Corps
    dashboardBody(

    tabItem(tabName = "sites",
            navbarPage(title = '',id = "visuobs", #fluid = TRUE,

                       tabPanel("Synthèse",value = "pr",
                                column(width=7,#premiere colonne
                                       box(width = 12, solidHeader = FALSE, status = "primary",
                                           leafletOutput("map",height = 700)
                                       )
                                ),#end premiere colonne
                                column(width=5,#deuxieme colonne
                                       box(width =12, solidHeader = FALSE, status = "primary",
                                       plotlyOutput('Graph_QJ',height = 400),
                                        p(),
                                        tableOutput("myTable")
                                       )
                                )#end deuxieme colonne

                       ) # end tab panel RR  

                ) # end navbar page
    ) # end tab item
  )
) # end dashboardbody







server <- function(input, output, session) {
  data <- reactiveValues(clickedMarker=NULL)
   #Carto synthese mesures Pit
  output$map <- renderLeaflet({

    map <- leaflet(data=myData) %>%  setView(3.3, 44.9, zoom = 7) %>%
      addLegend(position = "bottomright",
                title="Suivis Pit",
                colors = PALETTES$Suivi$colours,
                labels = c(paste(PALETTES$Suivi$distr,sep="")),
                opacity = 0.8) %>%
      #addTiles('http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}')%>%
      addProviderTiles("Thunderforest.Landscape",
                       options = providerTileOptions(noWrap = TRUE)) %>% 
      addMarkers(data=myData,popup=myData$LIB_LIEU,icon = ~quakeIcons[GROUP],clusterOptions = markerClusterOptions(),
                 layerId = myData$id)


   map




  }) # end renderLeaflet

  output$Graph_QJ <- renderPlotly({


  Graph_QJ



 }) # end plotlyGraph

  # observe si il y a un click sur un shape sur la carto
  observeEvent(input$map_marker_click,{
    print("observed map_marker_click")
    data$clickedMarker <- input$map_marker_click
    print(data$clickedMarker)
    output$myTable <- renderTable({
      return(
        subset(myData,id == data$clickedMarker$id)
      )

    })      


  }) #end 

}




shinyApp(shinyUI, server)

非常感谢你的帮助。

0 个答案:

没有答案