title: Shiny - how to highlight an object on a leaflet map when selecting a record in a datatable?
body: <p>Is there a way to highlight a marker or polyline on a leaflet map when selecting (clicking on) the corresponding record in a datatable?</p>
  
  <p>I looked at these questions/threads: </p>
  
  <p><a href="https://stackoverflow.com/questions/44834596/selecting-a-marker-on-leaflet-from-a-dt-row-click-and-vice-versa">selecting a marker on leaflet, from a DT row click and vice versa</a> - no answer</p>
  
  <p><a href="https://github.com/r-spatial/mapedit/issues/56" rel="noreferrer">https://github.com/r-spatial/mapedit/issues/56</a>  - check timelyportfolio's comment on Jul 23, 2017. As it shows in the gif, I would like to be able to select a row in the datatable so that the corresponding map object (marker/polyline) is highlighted as well (without editing the map).</p>
  
  <p>Here is a working example where the highlighted map object is selected in the datatable below but not vice versa - which is what I am trying to achieve.</p>
  
  <pre><code>##############################################################################
  # Libraries
  ##############################################################################
  library(shiny)
  library(shinythemes)
  library(ggplot2)
  library(plotly)
  library(leaflet)
  library(DT)
  ##############################################################################
  # Data
  ##############################################################################
  qDat &lt;- quakes
  qDat$id &lt;- seq.int(nrow(qDat))
  str(qDat)
  ##############################################################################
  # UI Side
  ##############################################################################
  ui &lt;- fluidPage(
    titlePanel("Visualization of Fiji Earthquake"),
  
    # side panel
    sidebarPanel(
      h3('Fiji Earthquake Data'),
  
      sliderInput(
        inputId = "sld01_Mag",
        label="Show earthquakes of magnitude:", 
        min=min(qDat$mag), max=max(qDat$mag),
        value=c(min(qDat$mag),max(qDat$mag)), step=0.1
        ),
  
      plotlyOutput('hist01')
      ),
  
    # main panel
    mainPanel(
      leafletOutput('map01'),
      dataTableOutput('table01')
      )
  
  )
  ##############################################################################
  # Server Side
  ##############################################################################
  server &lt;- function(input,output){
    qSub &lt;-  reactive({
  
        subset &lt;- subset(qDat, qDat$mag&gt;=input$sld01_Mag[1] &amp;
                           qDat$mag&lt;=input$sld01_Mag[2])
    })
  
    # histogram
    output$hist01 &lt;- renderPlotly({
      ggplot(data=qSub(), aes(x=stations)) + 
        geom_histogram(binwidth=5) +
        xlab('Number of Reporting Stations') +
        ylab('Count') +
        xlim(min(qDat$stations), max(qDat$stations))+
        ggtitle('Fiji Earthquake')
    })
  
    # table
    output$table01 &lt;- renderDataTable({
  
      DT::datatable(qSub(), selection = "single",options=list(stateSave = TRUE))
    })
  
    # map
    output$map01 &lt;- renderLeaflet({
      pal &lt;- colorNumeric("YlOrRd", domain=c(min(quakes$mag), max(quakes$mag)))
      qMap &lt;- leaflet(data = qSub()) %&gt;% 
        addTiles() %&gt;%
        addMarkers(popup=~as.character(mag), layerId = qSub()$id) %&gt;%
        addLegend("bottomright", pal = pal, values = ~mag,
                  title = "Earthquake Magnitude",
                  opacity = 1)
      qMap
    })
  
    observeEvent(input$map01_marker_click, {
      clickId &lt;- input$map01_marker_click$id
      dataTableProxy("table01") %&gt;%
        selectRows(which(qSub()$id == clickId)) %&gt;%
        selectPage(which(input$table01_rows_all == clickId) %/% input$table01_state$length + 1)
    })
  }
  
  ##############################################################################
  shinyApp(ui = ui, server = server)
  ##############################################################################
  </code></pre>
  
  <p>Any suggestions?</p>