From 8c8e0c34e08036410d90c7745f43c2a13e0abc9b Mon Sep 17 00:00:00 2001 From: olivroy Date: Fri, 9 Feb 2024 08:40:11 -0500 Subject: [PATCH 1/2] tmap_save returns filename invisibly --- R/tmap_save.R | 9 +++++---- man/tmap_save.Rd | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/R/tmap_save.R b/R/tmap_save.R index fb91af74b..b148c8f71 100644 --- a/R/tmap_save.R +++ b/R/tmap_save.R @@ -52,8 +52,9 @@ #' usually take more space then the map resources. #' @param verbose Deprecated. It is now controlled by the tmap option `show.messages` #' (see [tmap_options()]) -#' @param ... arguments passed on to device functions or to -#' [`saveWidget()`][htmlwidgets::saveWidget()] or [`saveWidgetFrame()`][widgetframe::saveWidgetframe()] +#' @inheritDotParams htmlwidgets::saveWidget +#' @inheritDotParams widgetframe::saveWidgetframe +#' @returns the filename, invisibly, if export is successful. #' @importFrom htmlwidgets saveWidget #' @import tmaptools #' @example ./examples/tmap_save.R @@ -151,7 +152,7 @@ tmap_save = function(tm=NULL, filename=NA, device=NULL, width=NA, height=NA, uni if (verbose) { message("Interactive map saved to ", suppressWarnings(normalizePath(filename))) } - return(invisible()) + return(invisible(filename)) } if (is.na(width) || is.na(height)) { @@ -265,7 +266,7 @@ tmap_save = function(tm=NULL, filename=NA, device=NULL, width=NA, height=NA, uni } } options(tmap.mode=tmap.mode) - invisible() + invisible(filename) } plot_device = function(device, ext, filename, dpi, units_target){ diff --git a/man/tmap_save.Rd b/man/tmap_save.Rd index 5775383ca..f9d3f5768 100644 --- a/man/tmap_save.Rd +++ b/man/tmap_save.Rd @@ -89,8 +89,21 @@ usually take more space then the map resources.} \item{verbose}{Deprecated. It is now controlled by the tmap option \code{show.messages} (see \code{\link[=tmap_options]{tmap_options()}})} -\item{...}{arguments passed on to device functions or to -\code{\link[htmlwidgets:saveWidget]{saveWidget()}} or \code{\link[widgetframe:saveWidgetframe]{saveWidgetFrame()}}} +\item{...}{ + Arguments passed on to \code{\link[htmlwidgets:saveWidget]{htmlwidgets::saveWidget}}, \code{\link[widgetframe:saveWidgetframe]{widgetframe::saveWidgetframe}} + \describe{ + \item{\code{widget}}{Widget to save} + \item{\code{file}}{File to save HTML into} + \item{\code{libdir}}{Directory to copy HTML dependencies into (defaults to +filename_files).} + \item{\code{background}}{Text string giving the html background color of the widget. +Defaults to white.} + \item{\code{title}}{Text to use as the title of the generated page.} + \item{\code{knitrOptions}}{A list of \pkg{knitr} chunk options.} + }} +} +\value{ +the filename, invisibly, if export is successful. } \description{ Save tmap to a file. This can be either a static plot (e.g. png) or an interactive map (html). From 1d8c4e45dcced4f706ad1378607189b0b4387b0c Mon Sep 17 00:00:00 2001 From: olivroy Date: Fri, 9 Feb 2024 08:43:43 -0500 Subject: [PATCH 2/2] document missing arguments --- R/print.R | 3 ++- man/print.tmap.Rd | 4 ++++ man/tmap_leaflet.Rd | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/R/print.R b/R/print.R index 18a1263e9..9b090bdac 100644 --- a/R/print.R +++ b/R/print.R @@ -4,9 +4,10 @@ #' @param return.asp should the aspect ratio be returned? #' @param show show the map #' @param vp viewport (for `"plot"` mode) +#' @param knit A logical, should knit? +#' @param options A vector of options #' @param ... not used #' @export -#' @method print tmap print.tmap = function(x, return.asp = FALSE, show = TRUE, vp = NULL, knit = FALSE, options = NULL, ...) { args = list(...) dev = getOption("tmap.devel.mode") diff --git a/man/print.tmap.Rd b/man/print.tmap.Rd index 52911eeba..ced9cc2df 100644 --- a/man/print.tmap.Rd +++ b/man/print.tmap.Rd @@ -26,6 +26,10 @@ knit_print.tmap(x, ..., options = NULL) \item{vp}{viewport (for \code{"plot"} mode)} +\item{knit}{A logical, should knit?} + +\item{options}{A vector of options} + \item{...}{not used} } \description{ diff --git a/man/tmap_leaflet.Rd b/man/tmap_leaflet.Rd index 2f92b33f6..93924697f 100644 --- a/man/tmap_leaflet.Rd +++ b/man/tmap_leaflet.Rd @@ -19,6 +19,8 @@ tmap_grid(x, show = FALSE, ...) \describe{ \item{\code{return.asp}}{should the aspect ratio be returned?} \item{\code{vp}}{viewport (for \code{"plot"} mode)} + \item{\code{knit}}{A logical, should knit?} + \item{\code{options}}{A vector of options} }} } \value{