这是indexloc提供的服务,不要输入任何密码
Skip to content

Fix doc + address one revdep issue + expose control.collapse #1016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ doc
# History files
.Rhistory
.Rapp.history

# Session Data files
.RData
# Example code in package build process
Expand Down Expand Up @@ -42,3 +41,5 @@ docs
inst/doc

tests/testthat/Rplots.pdf

.DS_Store
2 changes: 2 additions & 0 deletions R/docs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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).",
Expand Down
6 changes: 4 additions & 2 deletions R/tm_layout.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
Expand All @@ -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
Expand All @@ -49,6 +50,7 @@ tm_view = function(use_browser,
control.position,
control.bases,
control.overlays,
control.collapse,
set_bounds,
set_view,
set_zoom_limits,
Expand Down
4 changes: 2 additions & 2 deletions R/tmapLeafletComp_funs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
16 changes: 13 additions & 3 deletions R/tmap_mode.R
Original file line number Diff line number Diff line change
@@ -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()].
Expand All @@ -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
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions R/tmap_options.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")`
Expand All @@ -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")`
Expand Down Expand Up @@ -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")`
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Binary file removed man/.DS_Store
Binary file not shown.
8 changes: 4 additions & 4 deletions man/tm_layout.Rd

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

8 changes: 4 additions & 4 deletions man/tm_options.Rd

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

7 changes: 5 additions & 2 deletions man/tm_view.Rd

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

15 changes: 13 additions & 2 deletions man/tmap_mode.Rd

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

15 changes: 9 additions & 6 deletions man/tmap_options.Rd

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

4 changes: 2 additions & 2 deletions vignettes/12_foundations_crs.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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") +
Expand All @@ -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) +
Expand Down
Loading