trafficonese / leaflet.extras

Extra functionality for leaflet R package.
https://trafficonese.github.io/leaflet.extras/
GNU General Public License v3.0
216 stars 74 forks source link

Shiny input associated with search doesn't show up in list of inputs #76

Closed doug-friedman closed 7 years ago

doug-friedman commented 7 years ago

When I use the addSearchOSM function with leaflet (and leaflet.extras) in a Shiny application I cannot find the Shiny input you've bound to the location search results.

Here's a simple example where I constantly print the available inputs to the R console. Ideally, I should be able to access input$leaf_search_location_found.

library(shiny)
library(leaflet)
library(leaflet.extras)

ui = fluidPage(
  leafletOutput("leaf")
)

server = function(input, output){

  output$leaf =  renderLeaflet({
    breweries91 %>%
      leaflet() %>%
      addTiles() %>%
      addMarkers() %>%
      addSearchOSM()
  })

  observe({
    print(names(input))
  })

}

shinyApp(ui=ui, server=server)
bhaskarvk commented 7 years ago

Instead of your observe code try this

observeEvent(input$leaf_search_location_found,{
    print(input$leaf_search_location_found)
  })
bhaskarvk commented 7 years ago

Closing with the correct code provided. reopen if this doesn't work.