Skip to content

Commit

Permalink
update tmap_grob #905
Browse files Browse the repository at this point in the history
  • Loading branch information
mtennekes committed Nov 13, 2024
1 parent 280714c commit 58625eb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
11 changes: 7 additions & 4 deletions R/tmap_leaflet.R → R/tmap_export.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#' Export tmap to the format of the used graphics mode
#'
#'
#' * `tmap_grob()` returns a [`grob`][grid::grob()] object (`"plot" mode`)
#' * `tmap_leaflet()` a [`leaflet`][leaflet::leaflet()] object (`"view"` mode).
#'
#'
#' @param x a tmap object.
#' @param asp,scale the desired aspect ratio and scale of the map. Only applicable for `"plot"` mode.
#' @param show show the map?
#' @inheritDotParams print.tmap
#' @return
#' @return
#' * `tmap_grob()` returns a [`grob`][grid::grob()] object (`"plot"` mode)
#' * `tmap_leaflet()` a [`leaflet`][leaflet::leaflet()] object (`"view"` mode).
#' In case small multiples are shown, a list is returned.
Expand All @@ -32,12 +33,14 @@ tmap_leaflet = function(x,
#' @rdname tmap_leaflet
#' @export
tmap_grob = function(x,
asp = NA,
scale = 1,
show = FALSE,
...) {
current_mode = getOption("tmap.mode")
on.exit({
options(tmap.mode = current_mode)
})
options(tmap.mode = "plot")
print.tmap(x, show = show, ...)
print.tmap(x + tm_options(asp = asp, scale = scale), show = show, ...)
}
2 changes: 1 addition & 1 deletion man/tmap_animation.Rd

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

6 changes: 4 additions & 2 deletions man/tmap_leaflet.Rd

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

0 comments on commit 58625eb

Please sign in to comment.