diff --git a/.gitignore b/.gitignore index fc044fe18..0e02aafe6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ doc # History files .Rhistory .Rapp.history - # Session Data files .RData # Example code in package build process @@ -42,3 +41,5 @@ docs inst/doc tests/testthat/Rplots.pdf + +.DS_Store diff --git a/R/docs.R b/R/docs.R index 0427c58fa..1c7e194a7 100644 --- a/R/docs.R +++ b/R/docs.R @@ -84,6 +84,8 @@ absolute_fontsize = "absolute fontsize", x = "x", y = "y", + xlab = "`x` label", + ylab = "`y` label", zoom = "zoom") extra_lookup = c(margins = " A vector of 4 values: bottom, left, top, right. The unit is the device height (for bottom and top) or width (for left and right).", diff --git a/R/tm_layout.R b/R/tm_layout.R index 80d3c6f39..874e8a339 100644 --- a/R/tm_layout.R +++ b/R/tm_layout.R @@ -27,9 +27,10 @@ tm_layout = function( #' #' @param use_browser If `TRUE` it opens an external browser, and `FALSE` (default) it opens the internal IDEs (e.g. RStudio) browser. #' @param use_WebGL use webGL for points, lines, and polygons. This is much faster than the standard leaflet layer functions, but the number of visual variables are limited; only fill, size, and color (for lines) are supported. By default `TRUE` if no other visual variables are used. -#' @param control.position position of the control attribute +#' @param control.position `r .doc_opt("control.position")` #' @param control.bases base layers #' @param control.overlays overlay layers +#' @param control.collapse Should the box be collapsed or expanded? #' @param set_bounds logical that determines whether maximum bounds are set, #' or a bounding box. Not applicable in plot mode. #' In view mode, this is passed on to [setMaxBounds()][leaflet::setMaxBounds()] @@ -39,7 +40,7 @@ tm_layout = function( #' Only applicable if `bbox` is not specified #' @param set_zoom_limits numeric vector of two that set the minimum and maximum #' zoom levels (see [tileOptions()][leaflet::tileOptions()]). -#' @param use_circle_markers If `TRUE` (default) circle shaped symbols (e.g. `tm_dots` and `tm_symbols`) will be rendered as [addCircleMarkers()][leaflet::addCircleMarkers()] instead of [addMarkers()][leaflet::addMarkers()]. The former is faster, the latter can support any symbol since it is based on icons +#' @param use_circle_markers If `TRUE` (default) circle shaped symbols (e.g. `tm_dots()` and `tm_symbols()`) will be rendered as [addCircleMarkers()][leaflet::addCircleMarkers()] instead of [addMarkers()][leaflet::addMarkers()]. The former is faster, the latter can support any symbol since it is based on icons #' @param leaflet.options options passed on to #' [leafletOptions()][leaflet::leafletOptions()] #' @param ... to catch deprecated arguments @@ -49,6 +50,7 @@ tm_view = function(use_browser, control.position, control.bases, control.overlays, + control.collapse, set_bounds, set_view, set_zoom_limits, diff --git a/R/tmapLeafletComp_funs.R b/R/tmapLeafletComp_funs.R index 4e6890cf6..d9c39b705 100644 --- a/R/tmapLeafletComp_funs.R +++ b/R/tmapLeafletComp_funs.R @@ -22,7 +22,7 @@ tmapLeafletLegPlot.tm_title = function(comp, lf, o) { if (inherits(lf, "shiny.tag.list")) { ncld <- length(lf[[1]]) lf[[1]] <- mapply(function(l, i) { - title <- l$children[[1]]$title + title <- l$children[[1]]$title %||% "" if (title!="") { l$children[[1]] <- l$children[[1]] %>% htmlwidgets::onRender(paste(" function(el, x) { @@ -37,7 +37,7 @@ tmapLeafletLegPlot.tm_title = function(comp, lf, o) { l }, lf[[1]], 0:(ncld-1), SIMPLIFY = FALSE) } else { - title <- comp$text + title <- comp$text %||% "" if (title!="") { lf <- lf %>% htmlwidgets::onRender(paste(" function(el, x) { diff --git a/R/tmap_mode.R b/R/tmap_mode.R index 46b5906a1..bc882e702 100644 --- a/R/tmap_mode.R +++ b/R/tmap_mode.R @@ -1,5 +1,10 @@ #' Set tmap mode to static plotting or interactive viewing #' +#' @description +#' * `tmap_mode()` informs of the current mode (if called without argument). +#' * `ttm()` switches mode automatically. +#' * `ttmp()` switches mode and calls [tmap_last()] to display the last map in the other mode. +#' #' Set tmap mode to static plotting or interactive viewing. #' The global option `tmap.mode` determines the whether thematic maps are plot #' in the graphics device, or shown as an interactive leaflet map (see also [tmap_options()]. @@ -10,14 +15,15 @@ #' by [tmap_last()]; in order words, it shows the last map in the other mode. #' It is recommended to use `tmap_mode()` in scripts and `ttm()`/`ttmp()` in the console. #' -#' # mode = "plot" +#' @details +#' # `mode = "plot"` #' #' Thematic maps are shown in the graphics device. #' This is the default mode, and supports all tmap's features, #' such as small multiples (see [tm_facets()]) and extensive layout settings (see [tm_layout()]). #' It is recommended to use [tmap_save()] for saving static maps. #' -#' # mode = "view" +#' # `mode = "view"` #' #' Thematic maps are viewed interactively in the web browser or RStudio's Viewer pane. #' Maps are fully interactive with tiles from OpenStreetMap or other map providers @@ -39,7 +45,11 @@ #' However, the styling options still apply. #' #' @param mode One of `"plot"` or `"view"`. See Details for more info. -#' @return The previous tmap mode before switching. +#' @return +#' * `tmap_mode()` returns the current tmap mode invisibly (when called without argument). +#' Otherwise, returns the previous mode. +#' * `ttm()` switches mode and returns previous tmap mode invisibly. +#' The previous tmap mode before switching. #' @example ./examples/tmap_mode.R #' @seealso #' * [tmap_last()] to show the last map diff --git a/R/tmap_options.R b/R/tmap_options.R index f49d30fe8..329fe6a7e 100644 --- a/R/tmap_options.R +++ b/R/tmap_options.R @@ -45,7 +45,7 @@ #' adjusted to the size of the device divided by the number of columns and rows. #' @param bg.color Background color of the map. #' @param outer.bg.color Background color of map outside the frame. -#' @param frame `r .doc_opt("frame")` +#' @param frame Overall frame of the map #' @param frame.lwd `r .doc_opt("frame.lwd")` #' @param frame.r `r .doc_opt("frame.r")` #' @param frame.double_line `r .doc_opt("frame.double_line")` @@ -54,7 +54,7 @@ #' @param inner.margins.extra `r .doc_opt("inner.margins.extra")` #' @param meta.margins `r .doc_opt("meta.margins")` #' @param meta.auto_margins `r .doc_opt("meta.auto_margins")` -#' @param between_margin `r .doc_opt("between_margin")` +#' @param between_margin Margin between the map. #' @param panel.margin `r .doc_opt("panel.margin")` #' @param component.offset `r .doc_opt("component.offset")` #' @param component.stack_margin `r .doc_opt("component.stack_margin")` @@ -87,7 +87,7 @@ #' @param unit Unit of the coordinate #' @param color.sepia_intensity `r .doc_opt("color.sepia_intensity")` #' @param color.saturation `r .doc_opt("color.saturation")` -#' @param color_vision_deficiency_sim `r .doc_opt("color_vision_deficiency_sim")` +#' @param color_vision_deficiency_sim `Color vision deficiency simulation #' @param text.fontface `r .doc_opt("text.fontface")` #' @param text.fontfamily `r .doc_opt("text.fontfamily")` #' @param text.alpha `r .doc_opt("text.alpha")` @@ -306,7 +306,7 @@ #' @param qtm.scalebar `r .doc_opt("qtm.scalebar")` #' @param qtm.minimap `r .doc_opt("qtm.minimap")` #' @param qtm.mouse_coordinates `r .doc_opt("qtm.mouse_coordinates")` -#' @param earth_boundary `r .doc_opt("earth_boundary")` +#' @param earth_boundary The earth boundary #' @param earth_boundary.color `r .doc_opt("earth_boundary.color")` #' @param earth_boundary.lwd `r .doc_opt("earth_boundary.lwd")` #' @param earth_datum Earth datum @@ -336,7 +336,7 @@ tmap_options = function(..., crs, facet.max, facet.flip, free.scales, raster.max crs_extra, crs_global, use_gradient, # plot mode - use_browser, use_WebGL, control.position, control.bases, control.overlays, set_bounds, # view mode + use_browser, use_WebGL, control.position, control.bases, control.overlays, control.collapse, set_bounds, # view mode set_view, set_zoom_limits, use_circle_markers, leaflet.options, # view mode title = NULL, main.title = NULL, diff --git a/man/.DS_Store b/man/.DS_Store deleted file mode 100644 index bcecf0f1f..000000000 Binary files a/man/.DS_Store and /dev/null differ diff --git a/man/tm_layout.Rd b/man/tm_layout.Rd index 10343dc0b..3cb783283 100644 --- a/man/tm_layout.Rd +++ b/man/tm_layout.Rd @@ -305,7 +305,7 @@ adjusted to the size of the device divided by the number of columns and rows.} \item{outer.bg.color}{Background color of map outside the frame.} -\item{frame}{The frame of the .} +\item{frame}{Overall frame of the map} \item{frame.lwd}{The line width of the frame. See \code{graphics::par}, option 'lwd'.} @@ -323,7 +323,7 @@ adjusted to the size of the device divided by the number of columns and rows.} \item{meta.auto_margins}{The auto_margins of the meta.} -\item{between_margin}{The between_margin of the .} +\item{between_margin}{Margin between the map.} \item{panel.margin}{The margin of the panel.} @@ -389,7 +389,7 @@ adjusted to the size of the device divided by the number of columns and rows.} \item{color.saturation}{The saturation of the color.} -\item{color_vision_deficiency_sim}{The color_vision_deficiency_sim of the .} +\item{color_vision_deficiency_sim}{`Color vision deficiency simulation} \item{text.fontface}{The font face of the text. See \code{graphics::par}, option 'font'.} @@ -825,7 +825,7 @@ adjusted to the size of the device divided by the number of columns and rows.} \item{qtm.mouse_coordinates}{The mouse_coordinates of the qtm.} -\item{earth_boundary}{The earth_boundary of the .} +\item{earth_boundary}{The earth boundary} \item{earth_boundary.color}{The color of the earth_boundary.} diff --git a/man/tm_options.Rd b/man/tm_options.Rd index a0a9b20d1..e4d07bae5 100644 --- a/man/tm_options.Rd +++ b/man/tm_options.Rd @@ -384,7 +384,7 @@ adjusted to the size of the device divided by the number of columns and rows.} \item{outer.bg.color}{Background color of map outside the frame.} -\item{frame}{The frame of the .} +\item{frame}{Overall frame of the map} \item{frame.lwd}{The line width of the frame. See \code{graphics::par}, option 'lwd'.} @@ -402,7 +402,7 @@ adjusted to the size of the device divided by the number of columns and rows.} \item{meta.auto_margins}{The auto_margins of the meta.} -\item{between_margin}{The between_margin of the .} +\item{between_margin}{Margin between the map.} \item{panel.margin}{The margin of the panel.} @@ -468,7 +468,7 @@ adjusted to the size of the device divided by the number of columns and rows.} \item{color.saturation}{The saturation of the color.} -\item{color_vision_deficiency_sim}{The color_vision_deficiency_sim of the .} +\item{color_vision_deficiency_sim}{`Color vision deficiency simulation} \item{text.fontface}{The font face of the text. See \code{graphics::par}, option 'font'.} @@ -904,7 +904,7 @@ adjusted to the size of the device divided by the number of columns and rows.} \item{qtm.mouse_coordinates}{The mouse_coordinates of the qtm.} -\item{earth_boundary}{The earth_boundary of the .} +\item{earth_boundary}{The earth boundary} \item{earth_boundary.color}{The color of the earth_boundary.} diff --git a/man/tm_view.Rd b/man/tm_view.Rd index 336cb0ca9..9528d32a7 100644 --- a/man/tm_view.Rd +++ b/man/tm_view.Rd @@ -10,6 +10,7 @@ tm_view( control.position, control.bases, control.overlays, + control.collapse, set_bounds, set_view, set_zoom_limits, @@ -23,12 +24,14 @@ tm_view( \item{use_WebGL}{use webGL for points, lines, and polygons. This is much faster than the standard leaflet layer functions, but the number of visual variables are limited; only fill, size, and color (for lines) are supported. By default \code{TRUE} if no other visual variables are used.} -\item{control.position}{position of the control attribute} +\item{control.position}{The position of the control. A tm_pos object, or a shortcut of two values: horizontal (left, center, right) and vertical (top, center, bottom). See tm_pos for details} \item{control.bases}{base layers} \item{control.overlays}{overlay layers} +\item{control.collapse}{Should the box be collapsed or expanded?} + \item{set_bounds}{logical that determines whether maximum bounds are set, or a bounding box. Not applicable in plot mode. In view mode, this is passed on to \link[leaflet:map-methods]{setMaxBounds()}} @@ -41,7 +44,7 @@ Only applicable if \code{bbox} is not specified} \item{set_zoom_limits}{numeric vector of two that set the minimum and maximum zoom levels (see \link[leaflet:map-options]{tileOptions()}).} -\item{use_circle_markers}{If \code{TRUE} (default) circle shaped symbols (e.g. \code{tm_dots} and \code{tm_symbols}) will be rendered as \link[leaflet:map-layers]{addCircleMarkers()} instead of \link[leaflet:map-layers]{addMarkers()}. The former is faster, the latter can support any symbol since it is based on icons} +\item{use_circle_markers}{If \code{TRUE} (default) circle shaped symbols (e.g. \code{tm_dots()} and \code{tm_symbols()}) will be rendered as \link[leaflet:map-layers]{addCircleMarkers()} instead of \link[leaflet:map-layers]{addMarkers()}. The former is faster, the latter can support any symbol since it is based on icons} \item{leaflet.options}{options passed on to \link[leaflet:leaflet]{leafletOptions()}} diff --git a/man/tmap_mode.Rd b/man/tmap_mode.Rd index e9b279f79..2ecc0d751 100644 --- a/man/tmap_mode.Rd +++ b/man/tmap_mode.Rd @@ -16,9 +16,20 @@ ttmp() \item{mode}{One of \code{"plot"} or \code{"view"}. See Details for more info.} } \value{ +\itemize{ +\item \code{tmap_mode()} returns the current tmap mode invisibly (when called without argument). +Otherwise, returns the previous mode. +\item \code{ttm()} switches mode and returns previous tmap mode invisibly. The previous tmap mode before switching. } +} \description{ +\itemize{ +\item \code{tmap_mode()} informs of the current mode (if called without argument). +\item \code{ttm()} switches mode automatically. +\item \code{ttmp()} switches mode and calls \code{\link[=tmap_last]{tmap_last()}} to display the last map in the other mode. +} + Set tmap mode to static plotting or interactive viewing. The global option \code{tmap.mode} determines the whether thematic maps are plot in the graphics device, or shown as an interactive leaflet map (see also \code{\link[=tmap_options]{tmap_options()}}. @@ -29,14 +40,14 @@ toggle thematic map and print last map: it does the same as \code{ttm()} followe by \code{\link[=tmap_last]{tmap_last()}}; in order words, it shows the last map in the other mode. It is recommended to use \code{tmap_mode()} in scripts and \code{ttm()}/\code{ttmp()} in the console. } -\section{mode = "plot"}{ +\section{\code{mode = "plot"}}{ Thematic maps are shown in the graphics device. This is the default mode, and supports all tmap's features, such as small multiples (see \code{\link[=tm_facets]{tm_facets()}}) and extensive layout settings (see \code{\link[=tm_layout]{tm_layout()}}). It is recommended to use \code{\link[=tmap_save]{tmap_save()}} for saving static maps. } -\section{mode = "view"}{ +\section{\code{mode = "view"}}{ Thematic maps are viewed interactively in the web browser or RStudio's Viewer pane. Maps are fully interactive with tiles from OpenStreetMap or other map providers (see \code{\link[=tm_tiles]{tm_tiles()}}). See also \code{\link[=tm_view]{tm_view()}} for options related to the \code{"view"} mode. diff --git a/man/tmap_options.Rd b/man/tmap_options.Rd index c9218776e..79d1d885d 100644 --- a/man/tmap_options.Rd +++ b/man/tmap_options.Rd @@ -325,6 +325,7 @@ tmap_options( control.position, control.bases, control.overlays, + control.collapse, set_bounds, set_view, set_zoom_limits, @@ -411,7 +412,7 @@ adjusted to the size of the device divided by the number of columns and rows.} \item{outer.bg.color}{Background color of map outside the frame.} -\item{frame}{The frame of the .} +\item{frame}{Overall frame of the map} \item{frame.lwd}{The line width of the frame. See \code{graphics::par}, option 'lwd'.} @@ -429,7 +430,7 @@ adjusted to the size of the device divided by the number of columns and rows.} \item{meta.auto_margins}{The auto_margins of the meta.} -\item{between_margin}{The between_margin of the .} +\item{between_margin}{Margin between the map.} \item{panel.margin}{The margin of the panel.} @@ -495,7 +496,7 @@ adjusted to the size of the device divided by the number of columns and rows.} \item{color.saturation}{The saturation of the color.} -\item{color_vision_deficiency_sim}{The color_vision_deficiency_sim of the .} +\item{color_vision_deficiency_sim}{`Color vision deficiency simulation} \item{text.fontface}{The font face of the text. See \code{graphics::par}, option 'font'.} @@ -931,7 +932,7 @@ adjusted to the size of the device divided by the number of columns and rows.} \item{qtm.mouse_coordinates}{The mouse_coordinates of the qtm.} -\item{earth_boundary}{The earth_boundary of the .} +\item{earth_boundary}{The earth boundary} \item{earth_boundary.color}{The color of the earth_boundary.} @@ -971,12 +972,14 @@ adjusted to the size of the device divided by the number of columns and rows.} \item{use_WebGL}{use webGL for points, lines, and polygons. This is much faster than the standard leaflet layer functions, but the number of visual variables are limited; only fill, size, and color (for lines) are supported. By default \code{TRUE} if no other visual variables are used.} -\item{control.position}{position of the control attribute} +\item{control.position}{The position of the control. A tm_pos object, or a shortcut of two values: horizontal (left, center, right) and vertical (top, center, bottom). See tm_pos for details} \item{control.bases}{base layers} \item{control.overlays}{overlay layers} +\item{control.collapse}{Should the box be collapsed or expanded?} + \item{set_bounds}{logical that determines whether maximum bounds are set, or a bounding box. Not applicable in plot mode. In view mode, this is passed on to \link[leaflet:map-methods]{setMaxBounds()}} @@ -989,7 +992,7 @@ Only applicable if \code{bbox} is not specified} \item{set_zoom_limits}{numeric vector of two that set the minimum and maximum zoom levels (see \link[leaflet:map-options]{tileOptions()}).} -\item{use_circle_markers}{If \code{TRUE} (default) circle shaped symbols (e.g. \code{tm_dots} and \code{tm_symbols}) will be rendered as \link[leaflet:map-layers]{addCircleMarkers()} instead of \link[leaflet:map-layers]{addMarkers()}. The former is faster, the latter can support any symbol since it is based on icons} +\item{use_circle_markers}{If \code{TRUE} (default) circle shaped symbols (e.g. \code{tm_dots()} and \code{tm_symbols()}) will be rendered as \link[leaflet:map-layers]{addCircleMarkers()} instead of \link[leaflet:map-layers]{addMarkers()}. The former is faster, the latter can support any symbol since it is based on icons} \item{leaflet.options}{options passed on to \link[leaflet:leaflet]{leafletOptions()}} diff --git a/vignettes/12_foundations_crs.Rmd b/vignettes/12_foundations_crs.Rmd index ffc43cad8..83e1c4abd 100644 --- a/vignettes/12_foundations_crs.Rmd +++ b/vignettes/12_foundations_crs.Rmd @@ -146,7 +146,7 @@ tm_layout(earth_boundary = TRUE, frame = FALSE) ### Geometric transformations: use `tm_shape` -The `crs` can be defined in `tm_shape`. This is useful for thematic maps where the geometry is changed. For instance cartograms: +The `crs` can be defined in `tm_shape()`. This is useful for thematic maps where the geometry is changed. For instance cartograms: ```{r, fig.height = 3.5} tm_shape(World, crs = "+proj=robin") + @@ -155,7 +155,7 @@ tm_shape(World, crs = "+proj=robin") + ### Otherwise: use `tm_crs` -In the majority of use cases, e.g. regular choropleths, it is recommended to define the CRS with the function `tm_crs`: +In the majority of use cases, e.g. regular choropleths, it is recommended to define the CRS with the function `tm_crs()`: ```{r, fig.height = 3.5} tm_shape(World) +