Learn R Programming

leaflet.extras2 (version 1.0.0)

easyprintMap: easyprintMap

Description

Print or export a map programmatically (e.g. in a Shiny environment).

Usage

easyprintMap(map, sizeModes = "A4Portrait", filename = "map")

Arguments

map

the map widget

sizeModes

Options available include CurrentSize, A4Portrait, A4Landscape or a custom size object. Default is A4Portrait

filename

Name of the file if exportOnly option is TRUE.

Value

A leaflet map object

See Also

Other EasyPrint Functions: addEasyprint(), easyprintOptions(), removeEasyprint()

Examples

Run this code
# NOT RUN {
## 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)
}
# }

Run the code above in your browser using DataLab