mapshot: Save mapview or leaflet map as HTML and/or image

Description Usage Arguments Details See Also Examples

View source: R/mapshot.R

Description

Save a mapview or leaflet map as .html index file or .png, .pdf, or .jpeg image.

Usage

1
2
3
mapshot(x, url = NULL, file = NULL, remove_url = TRUE,
  remove_controls = c("zoomControl", "layersControl", "homeButton",
  "scaleBar"), ...)

Arguments

x

mapview or leaflet object.

url

Output .html file. If not supplied and 'file' is specified, a temporary index file will be created.

file

Output .png, .pdf, or .jpeg file.

remove_url

logical. If TRUE (default), the .html file is removed once processing is completed. Only applies if 'url' is not specified.

remove_controls

character vector of control buttons to be removed from the map when saving to file. Any combination of "zoomControl", "layersControl", "homeButton", "scaleBar". If set to NULL nothing will be removed.

...

Further arguments passed on to webshot.

Details

mapshot can be used to save both leaflet and mapview maps as html or png files or both.

NOTE 1: In case you want to save larger maps produced with mapview (i.e. if you see the following warning: "the supplied feature layer has more points/vertices than the set threshold. using special rendering function, hence things may not behave as expected from a standard leaflet map") mapshot is likely to fail. Try setting selfcontained = FALSE to avoid errors and create a valid local html file.

NOTE 2: In case you want to save a map with popupGraphs or popupImages the respective graph/image files will be located one level above the specified target location. In case you want to move the html file, make sure to also move the respective *-graphs folder one level above.

See Also

webshot, saveWidget.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
m <- mapview(breweries)

## create standalone .html
mapshot(m, url = paste0(getwd(), "/map.html"))

## create standalone .png; temporary .html is removed automatically unless
## 'remove_url = FALSE' is specified
mapshot(m, file = paste0(getwd(), "/map.png"))
mapshot(m, file = paste0(getwd(), "/map.png"),
        remove_controls = c("homeButton", "layersControl"))

## create .html and .png
mapshot(m, url = paste0(getwd(), "/map.html"),
        file = paste0(getwd(), "/map.png"))

## End(Not run)

r-spatial/mapview documentation built on Nov. 11, 2018, 12:27 p.m.