Code Monkey home page Code Monkey logo

Comments (6)

jcheng5 avatar jcheng5 commented on June 11, 2024

The htmlDependency is the right approach, I would think. Can you show me what you tried?

from shiny.

trafficonese avatar trafficonese commented on June 11, 2024

I tried some variations of this:

  map$dependencies <- c(map$dependencies,
                        leafletSearchDependencies(),
                        list(htmltools::htmlDependency(
                          "googlesearchapi", "0.0.1",
                          src = c(href = url),
                          script = "js?v=3",
                          all_files = FALSE
                        )))

from shiny.

trafficonese avatar trafficonese commented on June 11, 2024

actually, that seems to works and the error must be somewhere else..
The script tag with the URL + APIKEY gets appended add the end of the head-tag.

Thank you for your time!

from shiny.

trafficonese avatar trafficonese commented on June 11, 2024

I did some further testing and downloaded the Javascript into www/google.js that you get with this URL:
https://maps.googleapis.com/maps/api/js?v=3&key=API_KEY

This worked and the HTML head looked like this:
image

When using htmlDependency (I tried different orders)

  map$dependencies <- c(
                        list(htmltools::htmlDependency(
                          "googlesearchapi", "0.0.1",
                          src = c(href = url),
                          script = "",
                          all_files = TRUE
                        )),
                        map$dependencies,
                        leafletSearchDependencies()
                        )

I get the following errors:
image

and the head-tag looks like this:
image

I am not sure how I can control the order of the scripts or why not all google JS files get downloaded..
This is maybe more a question for htmltools or?

from shiny.

jcheng5 avatar jcheng5 commented on June 11, 2024

Can you try installing shiny 1.7.5.1? That will tell us if the async related changes to renderContent are causing this (I’m almost certain they are).

from shiny.

trafficonese avatar trafficonese commented on June 11, 2024

Still no success with shiny 1.7.5.1. (Also no luck with 1.7.4)

The html head looks identical to the one above (using htmlDependency).
Somehow the scripts log.js and geocoder.js are not included.

My session info
─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
setting  value
version  R version 4.3.1 (2023-06-16 ucrt)
os       Windows 11 x64 (build 22631)
system   x86_64, mingw32
ui       RStudio
language (EN)
collate  German_Austria.utf8
ctype    German_Austria.utf8
tz       Europe/Vienna
date     2024-03-11
rstudio  2023.06.0+421 Mountain Hydrangea (desktop)
pandoc   3.1.1 @ C:\\PROGRA~1\\RStudio\\RESOUR~1\\app\\bin\\quarto\\bin\\tools\\pandoc.exe

─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
package           * version date (UTC) lib source
bslib               0.5.1   2023-08-11 [1] CRAN (R 4.3.1)
cachem              1.0.8   2023-05-01 [1] CRAN (R 4.3.1)
cli                 3.6.1   2023-03-23 [1] CRAN (R 4.3.1)
crosstalk           1.2.0   2021-11-04 [1] CRAN (R 4.3.1)
digest              0.6.33  2023-07-07 [1] CRAN (R 4.3.1)
ellipsis            0.3.2   2021-04-29 [1] CRAN (R 4.3.1)
fastmap             1.1.1   2023-02-24 [1] CRAN (R 4.3.1)
htmltools           0.5.6   2023-08-10 [1] CRAN (R 4.3.1)
htmlwidgets         1.6.2   2023-03-17 [1] CRAN (R 4.3.1)
httpuv              1.6.11  2023-05-11 [1] CRAN (R 4.3.1)
jquerylib           0.1.4   2021-04-26 [1] CRAN (R 4.3.1)
jsonlite            1.8.7   2023-06-29 [1] CRAN (R 4.3.1)
later               1.3.1   2023-05-02 [1] CRAN (R 4.3.1)
leaflet           * 2.2.0   2023-08-31 [1] CRAN (R 4.3.1)
leaflet.extras    * 1.0.0   2024-03-11 [1] local
leaflet.providers   1.13.0  2023-08-10 [1] CRAN (R 4.3.1)
lifecycle           1.0.3   2022-10-07 [1] CRAN (R 4.3.1)
magrittr            2.0.3   2022-03-30 [1] CRAN (R 4.3.1)
memoise             2.0.1   2021-11-26 [1] CRAN (R 4.3.1)
mime                0.12    2021-09-28 [1] CRAN (R 4.3.0)
promises            1.2.1   2023-08-10 [1] CRAN (R 4.3.1)
R6                  2.5.1   2021-08-19 [1] CRAN (R 4.3.1)
Rcpp                1.0.11  2023-07-06 [1] CRAN (R 4.3.1)
rlang               1.1.1   2023-04-28 [1] CRAN (R 4.3.1)
rstudioapi          0.15.0  2023-07-07 [1] CRAN (R 4.3.1)
sass                0.4.7   2023-07-15 [1] CRAN (R 4.3.1)
sessioninfo         1.2.2   2021-12-06 [1] CRAN (R 4.3.1)
shiny             * 1.7.5.1 2023-10-14 [1] CRAN (R 4.3.1)
withr               2.5.1   2023-09-26 [1] CRAN (R 4.3.1)
xtable              1.8-4   2019-04-21 [1] CRAN (R 4.3.1)

from shiny.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.