leaflet.extras icon indicating copy to clipboard operation
leaflet.extras copied to clipboard

addSearchGoogle Not Working

Open chris-holcomb opened this issue 6 years ago • 7 comments

Getting the following message. It shows the OSM search but not Google:

Warning in origRenderFunc() : Ignoring appended content; appendContent can't be used in a Shiny render call

library(shiny); library(shinydashboard); library(leaflet); library(leaflet.extras)

ui <- dashboardPage(
  dashboardHeader(title = "Basic dashboard"),
  dashboardSidebar(
  ),
  dashboardBody(
        leafletOutput(outputId = "mymap1", width ="100%", height = "900px")
  )
)

server <- function(input, output) {
  output$mymap1 <- renderLeaflet({
    leaflet() %>% addProviderTiles(providers$Esri.WorldStreetMap) %>% 
      setView(lng = 174.768, lat = -36.852, 9) %>% 
      addSearchOSM() %>% 
      addSearchGoogle(apikey = YOURAPIKEY)
  })
  
}

shinyApp(ui, server)

devtools::session_info():

leaflet * 1.1.0.9000 2017-10-30 Github (rstudio/leaflet@d489e2c) leaflet..extras * 0.2.9002 2017-10-30 Github (bhaskarvk/leaflet.extras@23de9ea) shiny * 1.0.5.9000 2017-10-30 Github (rstudio/shiny@ba8d79f)

chris-holcomb avatar Oct 30 '17 19:10 chris-holcomb

Thanks, I will check it out.

bhaskarvk avatar Nov 06 '17 13:11 bhaskarvk

Hi there, any updates on this? :)

ghost avatar Jul 10 '18 05:07 ghost

Interested in the status on this.

jlbarr avatar Aug 16 '18 18:08 jlbarr

I'll be resuming development of leaflet.extras in Dec and will tackle this in that round. Thanks!

bhaskarvk avatar Nov 01 '18 15:11 bhaskarvk

Hi @bhaskarvk, I was planning to sign up for Google Business account, just for this feature to get the geocoding API key and I stumbled upon this open issue.

I already have signed up for MapQuest API but I wanted out-of-the-box solution for search bar on the leaflet map with autocomplete feature.

Given the addSearchGoogle() won't work, can you point out to the code for it, so may be I can try to replicate it for MapQuest API.

Apart from all this, thank you for your time and effort leaflet.extras has been very useful. Also, if you can point to the right direction, is there any way I can contribute to this project for this feature.

Thanks.

urwa avatar Oct 16 '19 14:10 urwa

Also,

I looked at the code in search.R and the relevant part of code is addSearchGoogle <- function( map, apikey = Sys.getenv("GOOGLE_MAP_GEOCODING_KEY"), options = searchOptions(autoCollapse = TRUE, minLength = 2) ) { url <- "https://maps.googleapis.com/maps/api/js?v=3" if (is.null(apikey)) { warning("Google Geocoding works best with an apikey") } else { url <- paste0(url, "&key=", apikey) } map$dependencies <- c(map$dependencies, leafletSearchDependencies()) invokeMethod( map, getMapData(map), "addSearchGoogle", options ) %>% htmlwidgets::appendContent(htmltools::tags$script(src = url)) }

I partially understand the code. I would really love to make this work.

Looking forward to your response.

urwa avatar Oct 16 '19 15:10 urwa

I opened an issue at Shiny https://github.com/rstudio/shiny/issues/3992

trafficonese avatar Mar 10 '24 14:03 trafficonese