继续从this问题,我正在寻找保存并下载一张传单地图作为PNG或JPEG图像。我有下面的代码,但我不断收到错误。如何在Shiny中保存传单地图
ui <- fluidPage(
leafletOutput("map"),
downloadButton("dl")
)
server <- function(input, output, session) {
output$map <- renderLeaflet({
leaflet() %>%
addTiles()
})
output$dl <- downloadHandler(
filename = "map.png",
content = function(file) {
mapshot(input[["map"]], file = file)
}
)
}
shinyApp(ui = ui, server = server)
我得到当我尝试下载(点击按钮)错误是
Warning: Error in system.file: 'package' must be of length 1
Stack trace (innermost first):
65: system.file
64: readLines
63: paste
62: yaml.load
61: yaml::yaml.load_file
60: getDependency
59: widget_dependencies
58: htmltools::attachDependencies
57: toHTML
56: <Anonymous>
55: do.call
54: mapshot
53: download$func [#11]
4: <Anonymous>
3: do.call
2: print.shiny.appobj
1: <Promise>
Error : 'package' must be of length 1
奖励积分,如果你能告诉我如何得到这个与leafletProxy
工作。
感谢您的建议,但不适合我 – nathaneastwood
工作并不适合你此代码的工作? 库(mapview) m < - 传单()%>%addTiles() mapshot(m,file =“map.png”) – SBista
啊 - 它正在运行,它只是需要一段时间才能运行。有趣的是,它只是下载灰色屏幕... – nathaneastwood