user7963169
user7963169

Reputation:

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")
```

Upvotes: 6

Views: 3241

Answers (2)

pax1a
pax1a

Reputation: 61

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

Upvotes: 6

cosworth
cosworth

Reputation: 25

Leaflet maps are good for an interactive display but not for an export. I use ggmap package to display statics maps the can be saved as PNG file.

Upvotes: -3

Related Questions