【发布时间】:2017-10-31 09:26:16
【问题描述】:
我需要使用传单中的 openstreet 地图制作用户定义地图的快照。我正在使用 saveWidget 保存一个 html 文件,然后使用 webshot 来拍摄该文件。它与 Esri.WorldStreetMap 等完美配合。但是,我无法使其与 Openstreetmap 一起使用。下面是一个最小的例子:
library(shiny)
library(leaflet)
library(webshot)
library(htmlwidgets)
ui <- fluidPage(
actionButton("button", "An action button")
)
server <- function(input, output, session) {
observeEvent(input$button,
{
themap<-leaflet() %>%
addProviderTiles("Openstreetmap.Mapnik")%>%
setView(lng=174.768, lat=-36.852,zoom=14)%>%
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")
saveWidget(themap, 'temp.html', selfcontained = T)
webshot('temp.html', file = "map.png",cliprect = viewport")
})
}
shinyApp(ui, server)
【问题讨论】:
标签: r shiny leaflet htmlwidgets