writing mapview object to .png with mapshot won't render legend
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.
Yes, see https://github.com/r-spatial/mapview/issues/423
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
Not that I know of. This is a very weird issue. Does it work in safari if you use webshot directly?
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.
What if you use htmlwidgets::saveWidget() first and then use webshot::webshot() on that html file?
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.
Sorry my oversight. webshot() should work if you pass it the @map slot of the mapview object