#' Group components
#'
#' @param group_id id of the component group. Refers to the `group_id` argument of each component function, such as [tm_legend()] and [tm_title()].
#' @param position The position specification of the components in this group: an object created with `tm_pos_in()` or `tm_pos_out()`. Or, as a shortcut, a vector of two values, specifying the x and y coordinates. The first is `"left"`, `"center"` or `"right"` (or upper case, meaning tighter to the map frame), the second `"top"`, `"center"` or `"bottom"`. Numeric values are also supported, where 0, 0 means left bottom and 1, 1 right top. See also \href{https://r-tmap.github.io/tmap/articles/adv_positions}{vignette about positioning}.
#' @param stack stacking `"horizontal"` or `"vertical"`
#' @param frame_combine put frame around all components that are drawn on the same location. Whether a frame is drawn is still decided by the `frame` argument of the 'main' (first) component.
#' @param equalize in case `frame_combine` is `FALSE`, should the separate frames be equalized, i.e. have the same width (when stacked vertically) or height (when stacked horizontally)?
#' @param resize_as_group in case a component if rescaled because of the limited space, rescale the other components proportionally?
#' @param stack_margin Margin between components
#' @param offset Offset margin between frame and the components block
#' @param frame Should a frame be drawn? By default `TRUE` for legends, charts and insets, and `FALSE` otherwise.
#' @param frame.color frame color
#' @param frame.alpha frame alpha transparancy
#' @param frame.lwd frame line width
#' @param frame.r Radius of the rounded frame corners. 0 means no rounding.
#' @param bg Background color the components block. Is usually set in each component function, but if specified here, it will overwrite them.
#' @param bg.color Background color the components block. Is usually set in each component function, but if specified here, it will overwrite them.
#' @param bg.alpha Background alpha transparency of the components block. Is usually set in each component function, but if specified here, it will overwrite them.
#' @return A [`tmap-element`]
#' @export
tm_comp_group = function(
group_id,
position,
stack, # was 'stack' in each tm_legend or tm_<comp> function
frame_combine,
equalize,
resize_as_group, # from tm_legend/tm_<comp>.
stack_margin, # margin between components
offset, # offset margin
frame ,
frame.color,
frame.alpha,
frame.lwd,
frame.r,
bg,
bg.color,
bg.alpha) {
args = lapply(as.list(rlang::call_match()[-1]), eval, envir = parent.frame())
optname = paste0("component_", group_id)
x = structure(list(args), names= optname)
do.call(tm_options, x)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.