Closed tnelsen closed 1 year ago
Are you using the CRAN or github (dev) version? Does this prevent the map loading?
We are using the dev version (2.7.6001). We are getting inconsistent behavior reported by our users with some reporting that the map is not loading. The map loads for me but I still get the ReferenceError.
In the very latest version I've added an 'initialiser callback' in the javascript code, to let shiny know when the google
object (map) is ready
Can you run this small example and see if you get the console error?
library(googleway)
library(shiny)
## set your key
# set_key(secret::get_secret("GOOGLE"))
ui <- fluidPage(
googleway::google_mapOutput(
outputId = "map"
)
)
server <- function(input, output, session) {
output$map <- googleway::renderGoogle_map({
google_map()
})
observeEvent(input$map_initialised, {
print(input$map_initialised)
})
}
shinyApp(ui, server)
The map renders fine but I am still seeing the error: Uncaught TypeError: Cannot read properties of undefined (reading 'Map') at google_map.js:53:51
did you get named list()
printed to your R console?
Yes. That's the only thing that is printed in the R console. named_list()
If it's helpful to see an example, here's one of our applications that is getting these errors. https://gcsxgsestimate.herokuapp.com/
In a new R Session, can you install the version that's on branch issue256
and let me know if you get the same console errors:
remotes::install_github("SymbolixAU/googleway", ref = "issue256")
and then run this small example again
library(googleway)
library(shiny)
set_key(secret::get_secret("GOOGLE"))
ui <- fluidPage(
googleway::google_mapOutput(
outputId = "map"
)
)
server <- function(input, output, session) {
output$map <- googleway::renderGoogle_map({
google_map()
})
observeEvent(input$map_initialised, {
print(input$map_initialised)
})
}
shinyApp(ui, server)
I do not get the same/any errors on the minimal example above!
ok that's progress! Any chance you can try it on one of your shiny's that's having issues?
I traced back the error to the geolocation returning NULL when the app is first loaded. On slower connections, this is more of an issue. I put a check in our apps to check if the geolocation is non-NULL and am no longer seeing the error anywhere.
am no longer seeing the error anywhere.
Is this on the issue256
branch still, or are you saying you're no longer seeing the issue using the master
branch?
We are no longer seeing the issue on either of the branches. I think the NULL check is what was needed to resolve the error :)
I am using the googleway package in several shiny applications and have been getting the error below over the past few weeks. It seems like the google_map.js file from the package is not being read properly. Is there a way to remedy this on my end? Thanks.