Print or export a map programmatically (e.g. in a Shiny environment).
Arguments
- map
the map widget
- sizeModes
Must match one of the given
sizeMode
names ineasyprintOptions
. The options are:CurrentSize
,A4Portrait
orA4Landscape
. If you want to print the map with aCustom
sizeMode you need to pass the Custom className. Default isA4Portrait
- filename
Name of the file if
exportOnly
option isTRUE
.
See also
Other EasyPrint Functions:
addEasyprint()
,
easyprintOptions()
,
removeEasyprint()
Examples
## Only run examples in interactive R sessions
if (interactive()) {
library(shiny)
library(leaflet)
library(leaflet.extras2)
ui <- fluidPage(
leafletOutput("map"),
selectInput("scene", "Select Scene", choices = c("CurrentSize", "A4Landscape", "A4Portrait")),
actionButton("print", "Print Map")
)
server <- function(input, output, session) {
output$map <- renderLeaflet({
input$print
leaflet() %>%
addTiles() %>%
setView(10, 50, 9) %>%
addEasyprint(options = easyprintOptions(
exportOnly = TRUE
))
})
observeEvent(input$print, {
leafletProxy("map") %>%
easyprintMap(sizeModes = input$scene)
})
}
shinyApp(ui, server)
}