it seem function leafletProxy is not working in htmlwidgets_0.6. the error message in console is
Couldn't find map with id map
I used the second example in this page: https://rstudio.github.io/leaflet/shiny.html
The latest version in the github has the same problem.
The htmlwidgets_0.5 is working fine with leafletProxy
Thanks for the heads up, I'll investigate.
I think I've fixed it. Can you try it again with one of these two builds?
devtools::install_github("rstudio/leaflet") # for latest (unstable)
or
devtools::install_github("rstudio/leaflet@joe/bugfix/htmlwidgets_0.6") # for CRAN patch (stable)
Thanks for your quick fix. It's working now for htmlwidgets_0.6
However, I find another bug for shinydashboard. You can find a minimum example from here: https://gist.github.com/byzheng/4dc969043439bf44217d
Shiny.onInputChange and works fine Shiny.onInputChange, but get the same error message (Couldn't find map with id map). PS: I noticed this error doesn't always happen especially click click me several times.My session infor:
R version 3.2.3 (2015-12-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
[5] LC_TIME=English_Australia.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] leaflet_1.0.1 shiny_0.13.0 shinydashboard_0.5.1
loaded via a namespace (and not attached):
[1] htmlwidgets_0.6 magrittr_1.5 R6_2.1.2 tools_3.2.3
[5] htmltools_0.3 yaml_2.1.13 Rcpp_0.12.3 jsonlite_0.9.19
[9] digest_0.6.9 xtable_1.8-2 httpuv_1.3.3 mime_0.4
I think I find the reason above error of shinydashboard. When shiny app is opening, the second itemMenu don't draw until the menu is clicked, so it makes sense the leaflet object map cannot find. So my current question is how to force to draw the leaflet map when page load.
On the server side can you try adding outputOptions(output, "map", suspendWhenHidden=FALSE) right after assigning output$map?
I've submitted Leaflet 1.0.1 to CRAN. Thanks again for the report. If the problem with shinydashboard persists, please submit a new issue. Thanks!
Hi all just as an FYI and hope this is helpful- I had this same issue without shinydashboard when trying to render a 2nd leaflet map on a separate tab. Tried updating leaflet, but adding outputOptions(output, "map", suspendWhenHidden=FALSE) fixed it.
Using Leaflet 2.0.2 - I still experience the issue. Adding outputOptions does not fix the issue in my case.
Most helpful comment
Using Leaflet 2.0.2 - I still experience the issue. Adding
outputOptionsdoes not fix the issue in my case.