saving R leaflet map as html: tiles not included

做~自己de王妃 提交于 2019-12-04 22:26:12

问题


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

回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/43783428/saving-r-leaflet-map-as-html-tiles-not-included

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!