0
我试图导出为可以保存,通过电子邮件发送等格式的png,jpg或ANY格式,一个简单的传单地图,带有从jpg文件制作的图标。基于htmlwidgets或mapview等建议尝试的每种方法都只给我一个带灰色背景(地图图层消失)图标的文件。然后发生一些奇怪的事情。即使我摆脱了自定义图标(从我的jpeg),现在我得到灰色的背景,蓝色的默认图标,仍然没有地图。在R中保存传单输出图
我已经尝试了每个解决方案在How to save Leaflet in R map as png or jpg file?,我最好得到图标层,但没有地图。
library(leaflet)
anna1Icon <- makeIcon(
iconUrl = "pic.jpg",
iconWidth = 2*31*215/230, iconHeight = 2*31,
iconAnchorX = 2*31*215/230/2, iconAnchorY = 2*16
)
my_map <- leaflet() %>%
addTiles() %>%
addMarkers(lat=44, lng=-93, popup="House", icon = anna1Icon)
解决方案的尝试1:
library(mapview)
mapshot(my_map, file = 'file.png')
解决方案尝试2:
library(htmlwidgets)
saveWidget(my_map, file="temp.html", selfcontained = FALSE)
webshot("temp.html", file = "output.png",
cliprect = "viewport")
帮助,谢谢!