Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving leaflet output as html

Tags:

html

r

leaflet

I am using RStudio to create some some leaflet images.

I would like to be able to save the output as an HTML so that it can be emailed and others can view it.

Below is some sample R code which was taken from [here] to create a sample leaflet image.

devtools::install_github('rstudio/leaflet') library(leaflet) rand_lng = function(n = 10) rnorm(n, -93.65, .01) rand_lat = function(n = 10) rnorm(n, 42.0285, .01) m = leaflet() %>% addTiles() %>% addCircles(rand_lng(50), rand_lat(50), radius = runif(50, 10, 200)) m 

Any code to be able to the output as HTML would be much appreciated...

like image 947
h.l.m Avatar asked May 07 '15 19:05

h.l.m


People also ask

How do you save a map on leaflet?

Yes, you can save leaflet objects as images. In the viewer tab, above the map, you will find an export button to save leaflets as an image.


1 Answers

Something like:

library(htmlwidgets) saveWidget(m, file="m.html") 

seems to work on most widgets.

like image 152
einar Avatar answered Oct 01 '22 20:10

einar