rshinywebshot

Is there a way to "pause" the `appshot()` function to allow Shiny App to fully render before running?


Context

I am working on a R package (called mapBliss) for making custom souvenir style maps which utilizes leaflet and the Mapbox-API.

Thanks to the help of SO I managed to figure out how to create a picture frame by using utilizing shiny and css.

My Question

I am looking to figure out how to take a screenshot of the picture that I made with the webshot package's appshot() function but for some reason I am unable to get it to capture the picture as I want it.

For the example, the code I am running produces the following (Shiny App) output:

# devtools::install_github("benyamindsmith/mapBliss")
library(mapBliss)

map<-plot_city_view("Jersalem, IL") |>
            frame_1(title_text="Jerusalem", 
                    subtitle_text="City of Gold", 
                    subtitle_font="Brush Script MT") 

map

enter image description here

If I want to capture the output using appshot() I get the following output:

library(webshot)

map |> appshot()

enter image description here

I assume its because appshot() is taking the screenshot before the shiny app fully renders. Is there a way to "delay" appshot() or is there another workaround?


Solution

  • Play with the vheight and delay parameters.

     plot_city_view("Jersalem, IL") |>
    frame_1(title_text="Jerusalem", subtitle_text="City of Gold", subtitle_font="Brush Script MT") |> 
    appshot(vheight = 1000, delay=10)