Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addSearchGoogle Not Working #112

Open
chris-holcomb opened this issue Oct 30, 2017 · 7 comments
Open

addSearchGoogle Not Working #112

chris-holcomb opened this issue Oct 30, 2017 · 7 comments

Comments

@chris-holcomb
Copy link

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)

@bhaskarvk
Copy link
Contributor

Thanks, I will check it out.

@ghost
Copy link

ghost commented Jul 10, 2018

Hi there, any updates on this? :)

@jlbarr
Copy link

jlbarr commented Aug 16, 2018

Interested in the status on this.

@bhaskarvk
Copy link
Contributor

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

@urwa
Copy link

urwa commented Oct 16, 2019

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
Copy link

urwa commented Oct 16, 2019

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.

@trafficonese
Copy link
Owner

I opened an issue at Shiny
rstudio/shiny#3992

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants