Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mapshot Error refers to webshot: Error in (function (url = NULL, file = "webshot.png", vwidth = 992, vheight = 744, : webshot.js returned failure value: 1 #112

Closed
KathaRRRina opened this issue May 3, 2022 · 8 comments · Fixed by #114

Comments

@KathaRRRina
Copy link

Hi there,
as I couldn't find a solution with this issue r-spatial/mapview#419, I got the advice to try it here.
This is my problem:

I am creating a Report with R Markdown and a part of it is based on maps that I create with leaflet. Then I use mapshot to create a jpg and save the map. So that I can load and show the jpg in the Report.

So far this worked fine, but since my last R update (Version 4.2.0) mapshot creates an Error. And unfortunately I can hardly find any support on this error online. Here is my reproducible example:

´´´
library("leaflet")
library("mapview")

m <- leaflet() %>%
addTiles() %>% # Add default OpenStreetMap map tiles
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")
m
mapshot(m, file = "C:/Rplot2.jpg")
´´´

This is the Error I get:

´´´
Could not load c:%5CUsers%5CVedi%5CAppData%5CLocal%5CTemp%5CRtmpqcG5qY%5Cfile36844d44770d.html
Error in (function (url = NULL, file = "webshot.png", vwidth = 992, vheight = 744, :
webshot.js returned failure value: 1
´´´

I have tried:

  • reinstallation of the needed packages, also of webshot
  • reinstallation of R and R Studio

The problem occurs on a laptop and on a server I use.

Any help is much appreciated!

@wch
Copy link
Owner

wch commented May 3, 2022

Does this work?

library(webshot)
webshot("https://www.r-project.org/", "r.png")

I suggest also trying to use webshot for a local HTML file, like this (replacing c:/..../file.html with the path to an actual HTML file on your computer):

webshot("c:/..../file.html", "test.png")

If those work, then the problem is likely to be related to mapshot.

@KathaRRRina
Copy link
Author

webshot("c:/..../file.html", "test.png")

Hi wch,
thank you for your answer! Your webshot example works for me. Where can I post issues that relate to mapshot? (I am new here)

@wch
Copy link
Owner

wch commented May 4, 2022

I think the original issue that you filed on the mapview repository is probably a good place to continue.

@carlinstarrs
Copy link

carlinstarrs commented May 24, 2022

I am getting this same error with webshot 0.5.3. Downgrading to 0.5.2 seemed to fix it for some reason. This was all I was trying to run (from the kableExtra package):

mtcars %>%
  kable() %>%
  kable_styling() %>%
  save_kable("test.png")

Both your examples shared above seemed to work with both 0.5.2 and 0.5.3.

Error message:

Could not load c:%5CUsers%5Cusername%5CAppData%5CLocal%5CTemp%5C2%5CRtmp2xUiuR%5Ctest22a032b4e20.html
Error in webshot::webshot(file_temp_html, file, ...) :
webshot.js returned failure value: 1

@c-brendel
Copy link

I am getting this same error with webshot 0.5.3. Downgrading to 0.5.2 seemed to fix it for some reason. This was all I was trying to run (from the kableExtra package):

mtcars %>%
  kable() %>%
  kable_styling() %>%
  save_kable("test.png")

Both your examples shared above seemed to work with both 0.5.2 and 0.5.3.

Error message:

Could not load c:%5CUsers%5Cusername%5CAppData%5CLocal%5CTemp%5C2%5CRtmp2xUiuR%5Ctest22a032b4e20.html Error in webshot::webshot(file_temp_html, file, ...) : webshot.js returned failure value: 1

I'm also saving Leaflet maps to HTML files and had the same error, but downgrading to 0.5.2 also solved the problem for me. I'm using Windows with R version 4.0.3

@wch
Copy link
Owner

wch commented Sep 26, 2022

Hm, I think there's a good chance this is due to #110.

@wch
Copy link
Owner

wch commented Sep 26, 2022

I just submitted a new version to CRAN with a fix for this issue.

@c-brendel
Copy link

I just checked my code again and now it works with webshot 0.5.4! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants