Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

saving R leaflet map as html: tiles not included

I am trying to save an R leaflet map, using saveWidget() or outputting an rmd-file to html - as described here: Saving leaflet output as html

When generating an html-file with markdown, the map will show fine in the internal rstudio viewer, however if I open the generated html file or the html-file produced by saveWidget() in a browser, only the circles are shown, not the tiles.

Minimal example:

```{r}
library(leaflet)
library(htmlwidgets)

m <- leaflet(data.frame(lat = 55.71654, lng = 12.47484))
m <-  addCircles(m, popup = "testpopup")
m <-  addTiles(m)
m
saveWidget(m, file="testmap.html")
```
like image 849
user7963169 Avatar asked May 04 '17 12:05

user7963169


1 Answers

Add %>% addProviderTiles(providers$OpenStreetMap), that worked for me. names(providers) gives you a list of the layers

like image 121
pax1a Avatar answered Oct 31 '22 20:10

pax1a