R/save_map.R

Defines functions save_map

Documented in save_map

#' Save interactive maps to html file
#'
#' @param x A leaflet class object e.g. as created with make_map.
#' @param file The file path where the output html file should be saved.
#'
#' @return The original object passed to the function unmodified.
#' @export
#'
#' @examples
#' \dontrun{
#'   collar_data %>%
#'   collar::make_map() %>%
#'   collar::save_map()
#' }

save_map <- function(
                     x,
                     file = "./map.html"
                     ) {

  assertthat::assert_that(inherits(x, "leaflet"))

  htmlwidgets::saveWidget(x, file = file)

  return(invisible(x))
}
Huh/CollaR documentation built on Aug. 8, 2022, 9:02 p.m.