将R传单地图另存为html:不包含图块 [英] saving R leaflet map as html: tiles not included
问题描述
我正在尝试使用saveWidget()或将rmd文件输出到html来保存R传单地图-如此处所述:
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
当生成带有markdown的html文件时,如果在打开的rstudio查看器中打开生成的html文件或saveWidget()生成的html文件,则地图会在内部rstudio查看器中很好地显示.在浏览器中,仅显示圆圈,而不显示图块.
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.
最小示例:
```{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")
```
推荐答案
添加对我有用的%>%addProviderTiles(providers $ OpenStreetMap). 名称(提供者)为您提供了层的列表
Add %>% addProviderTiles(providers$OpenStreetMap), that worked for me. names(providers) gives you a list of the layers
这篇关于将R传单地图另存为html:不包含图块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!