-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
165 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#' Map component: inset maps and other objects | ||
#' | ||
#' Map component that adds an inset object, e.g. a mini map | ||
#' | ||
#' @param x object to draw. Can be: bounding box, tmap object, ggplot2 object, grob object, image file name. | ||
#' @param height height of the component in number of text line heights. | ||
#' @param width width of the component in number of text line heights. | ||
#' @param margins margins | ||
#' @param between_margin Margin between | ||
#' @param stack stack with other map components, either `"vertical"` or `"horizontal"`. | ||
#' @inheritParams tm_title | ||
#' @param group.frame group.frame | ||
#' @param resize_as_group resize_as_group | ||
#' @param z z | ||
#' @example ./examples/tm_inset.R | ||
#' @export | ||
tm_inset = function(x = NULL, | ||
height, | ||
width, | ||
margins, | ||
between_margin, | ||
stack, | ||
position, | ||
frame, | ||
frame.lwd, | ||
frame.r, | ||
group.frame, | ||
resize_as_group, | ||
z) { | ||
args = lapply(as.list(rlang::call_match()[-1]), eval, envir = parent.frame()) | ||
args$z = args$z %||% NA_integer_ | ||
|
||
cls = if (is.null(x) || (inherits(x, "bbox"))) { | ||
"map" | ||
} else if (inherits(x, "tmap")) { | ||
"tmap" | ||
} else if (inherits(x, "ggplot")) { | ||
"gg" | ||
} else if (inherits(x, "grob")) { | ||
"grob" | ||
} else if (is.character(x)) { | ||
"image" | ||
} else { | ||
stop("Unsupported object") | ||
} | ||
|
||
cls2 = paste0("tm_inset_", cls) | ||
|
||
tm_element_list(do.call(tm_element, c(args, list(subclass = c(cls2, "tm_inset", "tm_component"))))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.