Skip to content

Commit

Permalink
Merge pull request #833 from olivroy/tmap-save
Browse files Browse the repository at this point in the history
tmap_save returns filename invisibly.
  • Loading branch information
mtennekes authored Feb 9, 2024
2 parents e69de4c + 1d8c4e4 commit 80bb9b0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
3 changes: 2 additions & 1 deletion R/print.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
9 changes: 5 additions & 4 deletions R/tmap_save.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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){
Expand Down
4 changes: 4 additions & 0 deletions man/print.tmap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/tmap_leaflet.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 15 additions & 2 deletions man/tmap_save.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 80bb9b0

Please sign in to comment.