qfes / rdeck

Deck.gl widget for R
https://qfes.github.io/rdeck
MIT License
98 stars 0 forks source link

Mapbox Tokens in Shiny? #63

Closed mrworthington closed 2 years ago

mrworthington commented 2 years ago

Hi,

I've loaded an R Deck into shinyapps.io. Everything works fine, except I can't seem to figure out a way to get my map box key to be read on shinyapps.io, so locally, you can see the mapbox tiles, but when it's hosted, the tiles are missing. Is there a way to do something akin to the following and have that token stored from the local environment onto the shiny app that gets hosted?


token <- Sys.get("MAPBOX_ACCESS_TOKEN")

rdeck::mapbox_access_token(token)

Local Render

Screen Shot 2022-04-06 at 9 24 54 PM

Shinyapps.io

Screen Shot 2022-04-06 at 9 25 12 PM
anthonynorth commented 2 years ago

Mapbox token can be set via environment variable MAPBOX_ACCESS_TOKEN or with option rdeck.mapbox_access_token. In shiny (own server, not shinyapps), we set the token via environment variable with {dotenv}.

I haven't used shinyapps, but I'm surprised it doesn't support supplying environment variables.

Edit: It appears that shinyapps supports .Renviron, so you might just put your token there.

mrworthington commented 2 years ago

Got it. That's what I did. Thanks!