1
#' Options for the interactive tmap viewer
2
#' 
3
#' Set the options for the interactive tmap viewer. Some of these options can also be set with \code{\link{tm_layout}}, since they are style dependent (e.g., the choice of basemaps). The function \code{tm_view} overrides these options when specified.
4
#' 
5
#' @param alpha transparency (opacity) parameter applied to whole map. By default, it is set to \code{0.7} if basemaps are used, and \code{1} otherwise.  
6
#' @param colorNA default color for missing values in interactive mode. If the color of missing values is not defined in the layer functions (e.g. \code{\link{tm_fill}}), then the default color is taken from the \code{na} value of the \code{aes.color} argument in \code{\link{tm_layout}}. This \code{colorNA} argument (if not \code{NA} itself) overrides that default value. For interactive maps, it can be useful to set \code{colorNA} to \code{NULL}, which means transparent.
7
#' @param projection projection. Either a EPSG number, or a \code{leaflet_crs} object created with \code{\link[leaflet:leafletCRS]{leafletCRS}}. By default, the Web Mercator (3857) is used, since the vast majority of basemaps are rendered accordingly. Other standards are EPSG numbers 4326 (WGS84) and 3395 (Mercator). If set to 0, the projection of the master shape is used (see \code{\link{tm_shape}}) provided that a EPSG number can be extracted.
8
#' @param symbol.size.fixed should symbol sizes be fixed while zooming?
9
#' @param dot.size.fixed should dot sizes be fixed while zooming?
10
#' @param text.size.variable should text size variables be allowed in view mode? By default \code{FALSE}, since in many applications, the main reason to vary text size is to prevent occlusion in plot mode, which is often not a problem in view mode due to the ability to zoom in.
11
#' @param bbox bounding box. One of the following:
12
#' \itemize{
13
#' \item A bounding box (an \code{\link[sf:sf]{sf}} bbox object, see \code{\link[sf:st_bbox]{st_bbox}}, a 2 by 2 matrix (used by the \code{sp} package), or an \code{\link[raster:Extent]{Extent}} object used by the \code{raster} package). 
14
#' \item Open Street Map search query. The bounding is automatically generated by querying \code{q} from Open Street Map Nominatim. See \url{http://wiki.openstreetmap.org/wiki/Nominatim}.}
15
#' If set, it overrides \code{set.view} and all bbox arguments of \code{\link{tm_shape}}.
16
#' @param set.bounds logical that determines whether maximum bounds are set, or a numeric vector of four values that specify the lng1, lat1, lng2, and lat2 coordinates (see \code{\link[leaflet:setMaxBounds]{setMaxBounds}}).
17
#' @param set.view numeric vector that determines the view. Either a vector of three: lng, lat, and zoom, or a single value: zoom. See \code{\link[leaflet:setView]{setView}}. Only applicable if \code{bbox} is not specified
18
#' @param set.zoom.limits numeric vector of two that set the minimum and maximum zoom levels (see \code{\link[leaflet:tileOptions]{tileOptions}}).
19
#' @param view.legend.position Character vector of two values, specifying the position of the legend. Use "left" or "right" for the first value and "top" or "bottom" for the second value. It overrides the value of \code{legend.position} of \code{\link{tm_layout}}, unless set to \code{NA}.
20
#' @param control.position Character vector of two values, specifying the position of the layer control UI. Use "left" or "right" for the first value and "top" or "bottom" for the second value.
21
#' @param popup.all.data not used anymore. As of version 1.6, the popups are specified by the argument \code{popup.vars} in the layer functions \code{\link{tm_fill}}, \code{\link{tm_symbols}}, and \code{\link{tm_lines}}.
22
#' @param legend.position not used anymore, renamed to view.legend.position
23
#' @param basemaps Deprecated. Use \code{\link{tm_basemap}} instead, or set the default basemaps in \code{\link{tmap_options}}
24
#' @param basemaps.alpha Deprecated. See \code{basemaps}
25
#' @example ./examples/tm_view.R
26
#' @seealso \href{../doc/tmap-getstarted.html}{\code{vignette("tmap-getstarted")}}
27
#' @references Tennekes, M., 2018, {tmap}: Thematic Maps in {R}, Journal of Statistical Software, 84(6), 1-39, \href{https://doi.org/10.18637/jss.v084.i06}{DOI}
28
#' @export
29
tm_view <- function(alpha,
30
					colorNA,
31
					projection,
32
					symbol.size.fixed,
33
					dot.size.fixed,
34
					text.size.variable,
35
					bbox,
36
					set.bounds,
37
					set.view,
38
					set.zoom.limits,
39
					view.legend.position,
40
					control.position,
41
					popup.all.data,
42
					legend.position,
43
					basemaps = NULL,
44
					basemaps.alpha = NULL) {
45 2
	e1 <- parent.frame()
46 2
	args <- lapply(as.list(match.call()[-1]), eval, envir = e1)
47 2
	args$style <- NA
48
	
49 2
	g <- list(tm_layout=args)
50 2
	class(g) <- "tm"
51 2
	g
52
}

Read our documentation on viewing source code .

Loading