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

writing mapview object to .png with mapshot won't render legend #434

Open
grantfalvo opened this issue Jul 18, 2022 · 7 comments
Open

writing mapview object to .png with mapshot won't render legend #434

grantfalvo opened this issue Jul 18, 2022 · 7 comments

Comments

@grantfalvo
Copy link

Hello,

I'm producing a map with a baselayer and an overlaid rasterlayer. The legend for the rasterlayer shows up fine in Rstudio but won't render when I save the mapview object as a .png with mapshot.

Any ideas on how to fix this?

Thanks.

@tim-salabim
Copy link
Member

Yes, see #423

@grantfalvo
Copy link
Author

I see, thanks for the tip.

I tried that and it looks like I have to install Chrome now to use webshot2 instead of webshot (I use Safari). Any work-around that doesn't require using Chrome?

Thanks

@tim-salabim
Copy link
Member

Not that I know of. This is a very weird issue. Does it work in safari if you use webshot directly?

@grantfalvo
Copy link
Author

With Safari, I can use mapshot with the CRAN version of mapview, but it doesn't render the legend when saved as a .png. When I use other versions of mapview (i.e. GitHub r-spatial versions) then it looks like I have to install Chrome to save the image.

@tim-salabim
Copy link
Member

What if you use htmlwidgets::saveWidget() first and then use webshot::webshot() on that html file?

@grantfalvo
Copy link
Author

Thanks for the quick responses.

I did save the mapview object as a local .html (using mapshot() because saveWidget() gave an '$ operator not defined for this S4 class' error). Then I used webshot:webshot() on that local .html file and got the same .png file without a legend. I'll note that I am able to save the mapview object as a .png with the legend when I export it from the RStudio viewer pane by hand.

@tim-salabim
Copy link
Member

Sorry my oversight. webshot() should work if you pass it the @map slot of the mapview object

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

No branches or pull requests

2 participants