save_webshot: Embedded webshot of leaflet map

View source: R/webshot.R

save_webshotR Documentation

Embedded webshot of leaflet map

Description

Embedded webshot of leaflet map

Usage

save_webshot(
  map,
  path_to_img,
  overwrite = FALSE,
  vwidth = 800,
  vheight = 600,
  cliprect = "viewport",
  ...
)

Arguments

map

A leaflet map object

path_to_img

A path to the image file to save

overwrite

Do you want to clobber any existing file?

vwidth

Viewport width. This is the width of the browser "window".

vheight

Viewport height This is the height of the browser "window".

cliprect

Clipping rectangle. If cliprect and selector are both unspecified, the clipping rectangle will contain the entire page. This can be the string "viewport", in which case the clipping rectangle matches the viewport size, or it can be a four-element numeric vector specifying the left, top, width, and height. (Note that the order of left and top is reversed from the original webshot package.) When taking screenshots of multiple URLs, this parameter can also be a list with same length as url with each element of the list being "viewport" or a four-elements numeric vector. This option is not compatible with selector.

...

arguments passed to webshot2::webshot()

Value

a path to a PNG file

Examples

## Not run: 
if (require(leaflet)) {
  map <- leaflet() |>
    addTiles() |>
    addMarkers(lng = 174.768, lat = -36.852, popup = "The birthplace of R")
  save_webshot(map, tempfile())
}

## End(Not run)

mdsr-book/mdsr documentation built on Aug. 23, 2024, 3:52 a.m.