I understand that this pretty much violates the purpose of using the interactive leaflet map, but I am writing a traditional paper book and I want to show how the leaflet package for R. works. I am writing a book in LaTeX and rendering with knitr . Is there a way to display the leaflet map as a bitmap so that it can be included in this book?
Here is a minimal example:
library(leaflet) map <- leaflet() %>% addTiles() %>% addMarkers(lng = -77.03673, lat = 38.89761)
Now, if I try a piece like:
<<>>= map @
I get this error:
Error in validateCssUnit(sizeInfo$width): "\maxwidth" is not a valid CSS unit (eg, "100%", "400px", "auto")
Trying to save as PNG doesn't work either:
<<>>= png(filename = "test.png") map dev.off() @
map not inherited from ggplot , so ggsave will not work either.
Is there any way to make this work?
source share