diff --git a/R/global-variables.R b/R/global-variables.R index 0affd798..97788246 100644 --- a/R/global-variables.R +++ b/R/global-variables.R @@ -18,7 +18,7 @@ utils::globalVariables(c( "outer.margins", "pages", "panel.label.height", "panel.labels", "panel.type", "panel.wrap.pos", "panel.xtab.pos", "pos.h", "pos.h.id", "pos.v", "pos.v.id", "red", "rows", "s1", "s2", "s3", "s4", - "scale.factor", "set.bounds", + "scale.factor", "set_bounds", "split_geometry_collection", "stack_auto", "t1", "t2", "t3", "t4", "text.fontface", "text.fontfamily", "title.bg.alpha", "tmapID__", "vneutral", diff --git a/R/messages.R b/R/messages.R index 8aeef30a..3d448273 100644 --- a/R/messages.R +++ b/R/messages.R @@ -97,3 +97,22 @@ error_dimvalues = function() { ) } +message_webgl_vars = function(supported, vary) { + sup_text = paste(supported, collapse = ", ") + var_text = paste(names(vary)[vary], collapse = ", ") + var_sel = names(vary)[vary] + + cli::cli_inform("{.field [view mode]} WegGL enabled, but the only supported visual variables are: {.val {supported}}. The visual variable(s) {.val {var_sel}} are not supported. Set {.code use_WebGL = FALSE} to support them.") + +} + +message_webgl_hover = function(type) { + cli::cli_inform("{.field [view mode]} WegGL enabled, but it does not support hover labels for layer type {.val {type}}. Set {.code use_WebGL = FALSE} to support them.") +} + + +message_webgl_checks = function(checks, checkif) { + vals = paste(paste(names(checkif)[!checks], checkif[!checks], sep = " = "), collapse = ", ") + cli::cli_inform("{.field [view mode]} WegGL enabled, but the following visual variable only accept one value {.arg {vals}}. Set {.code use_WebGL = FALSE} to support them.") + +} diff --git a/R/process_meta.R b/R/process_meta.R index 21bdae51..454fcef3 100644 --- a/R/process_meta.R +++ b/R/process_meta.R @@ -578,28 +578,28 @@ process_meta = function(o, d, cdt, aux) { legend.position = NA - if (!is.logical(set.bounds)) if (length(set.bounds) !=4 || !is.numeric(set.bounds)) stop("Incorrect set_bounds argument", call.=FALSE) + if (!is.logical(set_bounds)) if (length(set_bounds) !=4 || !is.numeric(set_bounds)) stop("Incorrect set_bounds argument", call.=FALSE) - if (!is.na(set.view[1])) { - if (!is.numeric(set.view)) stop("set.view is not numeric") - if (!length(set.view) %in% c(1, 3)) stop("set.view does not have length 1 or 3") + if (!is.na(set_view[1])) { + if (!is.numeric(set_view)) stop("set_view is not numeric") + if (!length(set_view) %in% c(1, 3)) stop("set_view does not have length 1 or 3") } - if (!is.na(set.zoom.limits[1])) { - if (!is.numeric(set.zoom.limits)) stop("set.zoom.limits is not numeric") - if (!length(set.zoom.limits)==2) stop("set.zoom.limits does not have length 2") - if (set.zoom.limits[1] >= set.zoom.limits[2]) stop("incorrect set.zoom.limits") + if (!is.na(set_zoom_limits[1])) { + if (!is.numeric(set_zoom_limits)) stop("set_zoom_limits is not numeric") + if (!length(set_zoom_limits)==2) stop("set_zoom_limits does not have length 2") + if (set_zoom_limits[1] >= set_zoom_limits[2]) stop("incorrect set_zoom_limits") } else { - set.zoom.limits <- c(NA, NA) + set_zoom_limits <- c(NA, NA) } - if (!is.na(set.view[1]) && !is.na(set.zoom.limits[1])) { - if (set.view[length(set.view)] < set.zoom.limits[1]) { + if (!is.na(set_view[1]) && !is.na(set_zoom_limits[1])) { + if (set_view[length(set_view)] < set_zoom_limits[1]) { if (show.warnings) warning("default zoom smaller than minimum zoom, now it is set to the minimum zoom") - set.view[length(set.view)] <- set.zoom.limits[1] + set_view[length(set_view)] <- set_zoom_limits[1] } - if (set.view[length(set.view)] > set.zoom.limits[2]) { + if (set_view[length(set_view)] > set_zoom_limits[2]) { if (show.warnings) warning("default zoom larger than maximum zoom, now it is set to the maximum zoom") - set.view[length(set.view)] <- set.zoom.limits[2] + set_view[length(set_view)] <- set_zoom_limits[2] } } diff --git a/R/step2_data.R b/R/step2_data.R index d95dad42..79acfeeb 100644 --- a/R/step2_data.R +++ b/R/step2_data.R @@ -95,12 +95,12 @@ step2_data = function(tm) { hover.data = if (tml$hover == "") { NULL } else { - as.character(dt[[tml$hover]]) + data.table(hover = as.character(dt[[tml$hover]]), tmapID__ = dt$tmapID__) } id.data = if (tml$id == "") { NULL } else { - as.character(dt[[tml$id]]) + data.table(id = as.character(dt[[tml$id]]), tmapID__ = dt$tmapID__) } format_called = attr(tml$popup.format, "called") diff --git a/R/tm_layout.R b/R/tm_layout.R index db1865cf..de353570 100644 --- a/R/tm_layout.R +++ b/R/tm_layout.R @@ -11,7 +11,7 @@ #' @name tm_layout #' @export tm_layout = function( - scale, asp, bg.color, outer.bg.color, frame, frame.lwd, frame.r, frame.double_line, outer.margins, inner.margins, inner.margins.extra, meta.margins, meta.auto_margins, between_margin, panel.margin, component.offset, component.stack_margin, grid.mark.height, xylab.height, coords.height, xlab.show, xlab.text, xlab.size, xlab.color, xlab.rotation, xlab.space, xlab.fontface, xlab.fontfamily, xlab.side, ylab.show, ylab.text, ylab.size, ylab.color, ylab.rotation, ylab.space, ylab.fontface, ylab.fontfamily, ylab.side, panel.type, panel.wrap.pos, panel.xtab.pos, unit, color.sepia_intensity, color.saturation, color_vision_deficiency_sim, text.fontface, text.fontfamily, component.position, component.autoscale, legend.show, legend.design, legend.orientation, legend.position, legend.width, legend.height, legend.stack, legend.group.frame, legend.resize_as_group, legend.reverse, legend.na.show, legend.title.color, legend.title.size, legend.title.fontface, legend.title.fontfamily, legend.xlab.color, legend.xlab.size, legend.xlab.fontface, legend.xlab.fontfamily, legend.ylab.color, legend.ylab.size, legend.ylab.fontface, legend.ylab.fontfamily, legend.text.color, legend.text.size, legend.text.fontface, legend.text.fontfamily, legend.frame, legend.frame.lwd, legend.frame.r, legend.bg.color, legend.bg.alpha, legend.only, legend.settings.standard.portrait, legend.settings.standard.landscape, chart.show, chart.plot.axis.x, chart.plot.axis.y, chart.position, chart.width, chart.height, chart.stack, chart.group.frame, chart.resize_as_group, chart.reverse, chart.na.show, chart.title.color, chart.title.size, chart.title.fontface, chart.title.fontfamily, chart.xlab.color, chart.xlab.size, chart.xlab.fontface, chart.xlab.fontfamily, chart.ylab.color, chart.ylab.size, chart.ylab.fontface, chart.ylab.fontfamily, chart.text.color, chart.text.size, chart.text.fontface, chart.text.fontfamily, chart.frame, chart.frame.lwd, chart.frame.r, chart.bg.color, chart.bg.alpha, chart.object.color, title.show, title.size, title.color, title.fontface, title.fontfamily, title.bg.color, title.bg.alpha, title.padding, title.frame, title.frame.lwd, title.frame.r, title.stack, title.position, title.width, title.group.frame, title.resize_as_group, credits.show, credits.size, credits.color, credits.fontface, credits.fontfamily, credits.bg.color, credits.bg.alpha, credits.padding, credits.frame, credits.frame.lwd, credits.frame.r, credits.stack, credits.position, credits.width, credits.height, credits.group.frame, credits.resize_as_group, compass.north, compass.type, compass.text.size, compass.size, compass.show.labels, compass.cardinal.directions, compass.text.color, compass.color.dark, compass.color.light, compass.lwd, compass.bg.color, compass.bg.alpha, compass.margins, compass.show, compass.stack, compass.position, compass.frame, compass.frame.lwd, compass.frame.r, compass.group.frame, compass.resize_as_group, logo.height, logo.margins, logo.between_margin, logo.show, logo.stack, logo.position, logo.frame, logo.frame.lwd, logo.frame.r, logo.group.frame, logo.resize_as_group, scalebar.show, scalebar.breaks, scalebar.width, scalebar.text.size, scalebar.text.color, scalebar.color.dark, scalebar.color.light, scalebar.lwd, scalebar.bg.color, scalebar.bg.alpha, scalebar.size, scalebar.margins, scalebar.stack, scalebar.position, scalebar.frame, scalebar.frame.lwd, scalebar.frame.r, scalebar.group.frame, scalebar.resize_as_group, grid.show, grid.labels.pos, grid.x, grid.y, grid.n.x, grid.n.y, grid.crs, grid.col, grid.lwd, grid.alpha, grid.labels.show, grid.labels.size, grid.labels.col, grid.labels.rot, grid.labels.format, grid.labels.cardinal, grid.labels.margin.x, grid.labels.margin.y, grid.labels.space.x, grid.labels.space.y, grid.labels.inside_frame, grid.ticks, grid.lines, grid.ndiscr, mouse_coordinates.stack, mouse_coordinates.position, mouse_coordinates.show, minimap.server, minimap.toggle, minimap.stack, minimap.position, minimap.show, panel.show, panel.labels, panel.label.size, panel.label.color, panel.label.fontface, panel.label.fontfamily, panel.label.bg.color, panel.label.frame, panel.label.frame.lwd, panel.label.frame.r, panel.label.height, panel.label.rot, bbox, set.bounds, set.view, set.zoom.limits, qtm.scalebar, qtm.minimap, qtm.mouse_coordinates, earth_boundary, earth_boundary.color, earth_boundary.lwd, earth_datum, space.color, check_and_fix, basemap.show, basemap.server, basemap.alpha, basemap.zoom, tiles.show, tiles.server, tiles.alpha, tiles.zoom, attr.color, + scale, asp, bg.color, outer.bg.color, frame, frame.lwd, frame.r, frame.double_line, outer.margins, inner.margins, inner.margins.extra, meta.margins, meta.auto_margins, between_margin, panel.margin, component.offset, component.stack_margin, grid.mark.height, xylab.height, coords.height, xlab.show, xlab.text, xlab.size, xlab.color, xlab.rotation, xlab.space, xlab.fontface, xlab.fontfamily, xlab.side, ylab.show, ylab.text, ylab.size, ylab.color, ylab.rotation, ylab.space, ylab.fontface, ylab.fontfamily, ylab.side, panel.type, panel.wrap.pos, panel.xtab.pos, unit, color.sepia_intensity, color.saturation, color_vision_deficiency_sim, text.fontface, text.fontfamily, component.position, component.autoscale, legend.show, legend.design, legend.orientation, legend.position, legend.width, legend.height, legend.stack, legend.group.frame, legend.resize_as_group, legend.reverse, legend.na.show, legend.title.color, legend.title.size, legend.title.fontface, legend.title.fontfamily, legend.xlab.color, legend.xlab.size, legend.xlab.fontface, legend.xlab.fontfamily, legend.ylab.color, legend.ylab.size, legend.ylab.fontface, legend.ylab.fontfamily, legend.text.color, legend.text.size, legend.text.fontface, legend.text.fontfamily, legend.frame, legend.frame.lwd, legend.frame.r, legend.bg.color, legend.bg.alpha, legend.only, legend.settings.standard.portrait, legend.settings.standard.landscape, chart.show, chart.plot.axis.x, chart.plot.axis.y, chart.position, chart.width, chart.height, chart.stack, chart.group.frame, chart.resize_as_group, chart.reverse, chart.na.show, chart.title.color, chart.title.size, chart.title.fontface, chart.title.fontfamily, chart.xlab.color, chart.xlab.size, chart.xlab.fontface, chart.xlab.fontfamily, chart.ylab.color, chart.ylab.size, chart.ylab.fontface, chart.ylab.fontfamily, chart.text.color, chart.text.size, chart.text.fontface, chart.text.fontfamily, chart.frame, chart.frame.lwd, chart.frame.r, chart.bg.color, chart.bg.alpha, chart.object.color, title.show, title.size, title.color, title.fontface, title.fontfamily, title.bg.color, title.bg.alpha, title.padding, title.frame, title.frame.lwd, title.frame.r, title.stack, title.position, title.width, title.group.frame, title.resize_as_group, credits.show, credits.size, credits.color, credits.fontface, credits.fontfamily, credits.bg.color, credits.bg.alpha, credits.padding, credits.frame, credits.frame.lwd, credits.frame.r, credits.stack, credits.position, credits.width, credits.height, credits.group.frame, credits.resize_as_group, compass.north, compass.type, compass.text.size, compass.size, compass.show.labels, compass.cardinal.directions, compass.text.color, compass.color.dark, compass.color.light, compass.lwd, compass.bg.color, compass.bg.alpha, compass.margins, compass.show, compass.stack, compass.position, compass.frame, compass.frame.lwd, compass.frame.r, compass.group.frame, compass.resize_as_group, logo.height, logo.margins, logo.between_margin, logo.show, logo.stack, logo.position, logo.frame, logo.frame.lwd, logo.frame.r, logo.group.frame, logo.resize_as_group, scalebar.show, scalebar.breaks, scalebar.width, scalebar.text.size, scalebar.text.color, scalebar.color.dark, scalebar.color.light, scalebar.lwd, scalebar.bg.color, scalebar.bg.alpha, scalebar.size, scalebar.margins, scalebar.stack, scalebar.position, scalebar.frame, scalebar.frame.lwd, scalebar.frame.r, scalebar.group.frame, scalebar.resize_as_group, grid.show, grid.labels.pos, grid.x, grid.y, grid.n.x, grid.n.y, grid.crs, grid.col, grid.lwd, grid.alpha, grid.labels.show, grid.labels.size, grid.labels.col, grid.labels.rot, grid.labels.format, grid.labels.cardinal, grid.labels.margin.x, grid.labels.margin.y, grid.labels.space.x, grid.labels.space.y, grid.labels.inside_frame, grid.ticks, grid.lines, grid.ndiscr, mouse_coordinates.stack, mouse_coordinates.position, mouse_coordinates.show, minimap.server, minimap.toggle, minimap.stack, minimap.position, minimap.show, panel.show, panel.labels, panel.label.size, panel.label.color, panel.label.fontface, panel.label.fontfamily, panel.label.bg.color, panel.label.frame, panel.label.frame.lwd, panel.label.frame.r, panel.label.height, panel.label.rot, bbox, set_bounds, set_view, set_zoom_limits, qtm.scalebar, qtm.minimap, qtm.mouse_coordinates, earth_boundary, earth_boundary.color, earth_boundary.lwd, earth_datum, space.color, check_and_fix, basemap.show, basemap.server, basemap.alpha, basemap.zoom, tiles.show, tiles.server, tiles.alpha, tiles.zoom, attr.color, title = NULL, ... @@ -26,40 +26,37 @@ tm_layout = function( #' #' View mode options. These options are specific to the view mode. #' -#' @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 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.bases base layers #' @param control.overlays overlay layers -#' @param set.bounds logical that determines whether maximum bounds are set, +#' @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()] -#' @param set.view numeric vector that determines the view. +#' @param set_view numeric vector that determines the view. #' Either a vector of three: `lng`, `lat`, and `zoom`, or a single value: #' `zoom`. See [setView()][leaflet::setView()]. #' Only applicable if `bbox` is not specified -#' @param set.zoom.limits numeric vector of two that set the minimum and maximum +#' @param set_zoom_limits numeric vector of two that set the minimum and maximum #' zoom levels (see [tileOptions()][leaflet::tileOptions()]). #' @param leaflet.options options passed on to #' [leafletOptions()][leaflet::leafletOptions()] -#' @param view.legend.position deprecated. Use `legend.position`from `tm_layout()` instead. +#' @param ... to catch deprecated arguments #' @export -tm_view = function(use.WebGL, +tm_view = function(use_WebGL, control.position, control.bases, control.overlays, - set.bounds, - set.view, - set.zoom.limits, + set_bounds, + set_view, + set_zoom_limits, leaflet.options, - view.legend.position = NULL) { - args = lapply(as.list(rlang::call_match()[-1]), eval, envir = parent.frame()) - - if (!is.null(view.legend.position)) { - args$legend.position = view.legend.position - args$view.legend.position = NULL - } + ...) { + args = lapply(as.list(rlang::call_match(dots_expand = TRUE)[-1]), eval, envir = parent.frame()) + args$called_from = "tm_view" do.call(tm_options, args) + } #' Plot mode options diff --git a/R/tm_options.R b/R/tm_options.R index 1f4bd28b..27872a0b 100644 --- a/R/tm_options.R +++ b/R/tm_options.R @@ -3,7 +3,7 @@ #' @inheritParams tmap_options #' @param style style see `tm_style()` #' @export -tm_options = function(crs, facet.max, facet.flip, free.scales, raster.max_cells, show.messages, show.warnings, output.format, output.size, output.dpi, animation.dpi, value.const, value.na, value.null, value.blank, values.var, values.range, value.neutral, values.scale, scales.var, scale.misc.args, continuous.nclass_per_legend_break, continuous.nclasses, label.format, label.na, scale, asp, bg.color, outer.bg.color, frame, frame.lwd, frame.r, frame.double_line, outer.margins, inner.margins, inner.margins.extra, meta.margins, meta.auto_margins, between_margin, panel.margin, component.offset, component.stack_margin, grid.mark.height, xylab.height, coords.height, xlab.show, xlab.text, xlab.size, xlab.color, xlab.rotation, xlab.space, xlab.fontface, xlab.fontfamily, xlab.side, ylab.show, ylab.text, ylab.size, ylab.color, ylab.rotation, ylab.space, ylab.fontface, ylab.fontfamily, ylab.side, panel.type, panel.wrap.pos, panel.xtab.pos, unit, color.sepia_intensity, color.saturation, color_vision_deficiency_sim, text.fontface, text.fontfamily, component.position, component.autoscale, legend.show, legend.design, legend.orientation, legend.position, legend.width, legend.height, legend.stack, legend.group.frame, legend.resize_as_group, legend.reverse, legend.na.show, legend.title.color, legend.title.size, legend.title.fontface, legend.title.fontfamily, legend.xlab.color, legend.xlab.size, legend.xlab.fontface, legend.xlab.fontfamily, legend.ylab.color, legend.ylab.size, legend.ylab.fontface, legend.ylab.fontfamily, legend.text.color, legend.text.size, legend.text.fontface, legend.text.fontfamily, legend.frame, legend.frame.lwd, legend.frame.r, legend.bg.color, legend.bg.alpha, legend.only, legend.settings.standard.portrait, legend.settings.standard.landscape, chart.show, chart.plot.axis.x, chart.plot.axis.y, chart.position, chart.width, chart.height, chart.stack, chart.group.frame, chart.resize_as_group, chart.reverse, chart.na.show, chart.title.color, chart.title.size, chart.title.fontface, chart.title.fontfamily, chart.xlab.color, chart.xlab.size, chart.xlab.fontface, chart.xlab.fontfamily, chart.ylab.color, chart.ylab.size, chart.ylab.fontface, chart.ylab.fontfamily, chart.text.color, chart.text.size, chart.text.fontface, chart.text.fontfamily, chart.frame, chart.frame.lwd, chart.frame.r, chart.bg.color, chart.bg.alpha, chart.object.color, title.show, title.size, title.color, title.fontface, title.fontfamily, title.bg.color, title.bg.alpha, title.padding, title.frame, title.frame.lwd, title.frame.r, title.stack, title.position, title.width, title.group.frame, title.resize_as_group, credits.show, credits.size, credits.color, credits.fontface, credits.fontfamily, credits.bg.color, credits.bg.alpha, credits.padding, credits.frame, credits.frame.lwd, credits.frame.r, credits.stack, credits.position, credits.width, credits.height, credits.group.frame, credits.resize_as_group, compass.north, compass.type, compass.text.size, compass.size, compass.show.labels, compass.cardinal.directions, compass.text.color, compass.color.dark, compass.color.light, compass.lwd, compass.bg.color, compass.bg.alpha, compass.margins, compass.show, compass.stack, compass.position, compass.frame, compass.frame.lwd, compass.frame.r, compass.group.frame, compass.resize_as_group, logo.height, logo.margins, logo.between_margin, logo.show, logo.stack, logo.position, logo.frame, logo.frame.lwd, logo.frame.r, logo.group.frame, logo.resize_as_group, scalebar.show, scalebar.breaks, scalebar.width, scalebar.text.size, scalebar.text.color, scalebar.color.dark, scalebar.color.light, scalebar.lwd, scalebar.bg.color, scalebar.bg.alpha, scalebar.size, scalebar.margins, scalebar.stack, scalebar.position, scalebar.frame, scalebar.frame.lwd, scalebar.frame.r, scalebar.group.frame, scalebar.resize_as_group, grid.show, grid.labels.pos, grid.x, grid.y, grid.n.x, grid.n.y, grid.crs, grid.col, grid.lwd, grid.alpha, grid.labels.show, grid.labels.size, grid.labels.col, grid.labels.rot, grid.labels.format, grid.labels.cardinal, grid.labels.margin.x, grid.labels.margin.y, grid.labels.space.x, grid.labels.space.y, grid.labels.inside_frame, grid.ticks, grid.lines, grid.ndiscr, mouse_coordinates.stack, mouse_coordinates.position, mouse_coordinates.show, minimap.server, minimap.toggle, minimap.stack, minimap.position, minimap.show, panel.show, panel.labels, panel.label.size, panel.label.color, panel.label.fontface, panel.label.fontfamily, panel.label.bg.color, panel.label.frame, panel.label.frame.lwd, panel.label.frame.r, panel.label.height, panel.label.rot, bbox, set.bounds, set.view, set.zoom.limits, qtm.scalebar, qtm.minimap, qtm.mouse_coordinates, earth_boundary, earth_boundary.color, earth_boundary.lwd, earth_datum, space.color, check_and_fix, basemap.show, basemap.server, basemap.alpha, basemap.zoom, tiles.show, tiles.server, tiles.alpha, tiles.zoom, attr.color, +tm_options = function(crs, facet.max, facet.flip, free.scales, raster.max_cells, show.messages, show.warnings, output.format, output.size, output.dpi, animation.dpi, value.const, value.na, value.null, value.blank, values.var, values.range, value.neutral, values.scale, scales.var, scale.misc.args, continuous.nclass_per_legend_break, continuous.nclasses, label.format, label.na, scale, asp, bg.color, outer.bg.color, frame, frame.lwd, frame.r, frame.double_line, outer.margins, inner.margins, inner.margins.extra, meta.margins, meta.auto_margins, between_margin, panel.margin, component.offset, component.stack_margin, grid.mark.height, xylab.height, coords.height, xlab.show, xlab.text, xlab.size, xlab.color, xlab.rotation, xlab.space, xlab.fontface, xlab.fontfamily, xlab.side, ylab.show, ylab.text, ylab.size, ylab.color, ylab.rotation, ylab.space, ylab.fontface, ylab.fontfamily, ylab.side, panel.type, panel.wrap.pos, panel.xtab.pos, unit, color.sepia_intensity, color.saturation, color_vision_deficiency_sim, text.fontface, text.fontfamily, component.position, component.autoscale, legend.show, legend.design, legend.orientation, legend.position, legend.width, legend.height, legend.stack, legend.group.frame, legend.resize_as_group, legend.reverse, legend.na.show, legend.title.color, legend.title.size, legend.title.fontface, legend.title.fontfamily, legend.xlab.color, legend.xlab.size, legend.xlab.fontface, legend.xlab.fontfamily, legend.ylab.color, legend.ylab.size, legend.ylab.fontface, legend.ylab.fontfamily, legend.text.color, legend.text.size, legend.text.fontface, legend.text.fontfamily, legend.frame, legend.frame.lwd, legend.frame.r, legend.bg.color, legend.bg.alpha, legend.only, legend.settings.standard.portrait, legend.settings.standard.landscape, chart.show, chart.plot.axis.x, chart.plot.axis.y, chart.position, chart.width, chart.height, chart.stack, chart.group.frame, chart.resize_as_group, chart.reverse, chart.na.show, chart.title.color, chart.title.size, chart.title.fontface, chart.title.fontfamily, chart.xlab.color, chart.xlab.size, chart.xlab.fontface, chart.xlab.fontfamily, chart.ylab.color, chart.ylab.size, chart.ylab.fontface, chart.ylab.fontfamily, chart.text.color, chart.text.size, chart.text.fontface, chart.text.fontfamily, chart.frame, chart.frame.lwd, chart.frame.r, chart.bg.color, chart.bg.alpha, chart.object.color, title.show, title.size, title.color, title.fontface, title.fontfamily, title.bg.color, title.bg.alpha, title.padding, title.frame, title.frame.lwd, title.frame.r, title.stack, title.position, title.width, title.group.frame, title.resize_as_group, credits.show, credits.size, credits.color, credits.fontface, credits.fontfamily, credits.bg.color, credits.bg.alpha, credits.padding, credits.frame, credits.frame.lwd, credits.frame.r, credits.stack, credits.position, credits.width, credits.height, credits.group.frame, credits.resize_as_group, compass.north, compass.type, compass.text.size, compass.size, compass.show.labels, compass.cardinal.directions, compass.text.color, compass.color.dark, compass.color.light, compass.lwd, compass.bg.color, compass.bg.alpha, compass.margins, compass.show, compass.stack, compass.position, compass.frame, compass.frame.lwd, compass.frame.r, compass.group.frame, compass.resize_as_group, logo.height, logo.margins, logo.between_margin, logo.show, logo.stack, logo.position, logo.frame, logo.frame.lwd, logo.frame.r, logo.group.frame, logo.resize_as_group, scalebar.show, scalebar.breaks, scalebar.width, scalebar.text.size, scalebar.text.color, scalebar.color.dark, scalebar.color.light, scalebar.lwd, scalebar.bg.color, scalebar.bg.alpha, scalebar.size, scalebar.margins, scalebar.stack, scalebar.position, scalebar.frame, scalebar.frame.lwd, scalebar.frame.r, scalebar.group.frame, scalebar.resize_as_group, grid.show, grid.labels.pos, grid.x, grid.y, grid.n.x, grid.n.y, grid.crs, grid.col, grid.lwd, grid.alpha, grid.labels.show, grid.labels.size, grid.labels.col, grid.labels.rot, grid.labels.format, grid.labels.cardinal, grid.labels.margin.x, grid.labels.margin.y, grid.labels.space.x, grid.labels.space.y, grid.labels.inside_frame, grid.ticks, grid.lines, grid.ndiscr, mouse_coordinates.stack, mouse_coordinates.position, mouse_coordinates.show, minimap.server, minimap.toggle, minimap.stack, minimap.position, minimap.show, panel.show, panel.labels, panel.label.size, panel.label.color, panel.label.fontface, panel.label.fontfamily, panel.label.bg.color, panel.label.frame, panel.label.frame.lwd, panel.label.frame.r, panel.label.height, panel.label.rot, bbox, set_bounds, set_view, set_zoom_limits, qtm.scalebar, qtm.minimap, qtm.mouse_coordinates, earth_boundary, earth_boundary.color, earth_boundary.lwd, earth_datum, space.color, check_and_fix, basemap.show, basemap.server, basemap.alpha, basemap.zoom, tiles.show, tiles.server, tiles.alpha, tiles.zoom, attr.color, title = NULL, main.title = NULL, main.title.size = NULL, @@ -11,7 +11,6 @@ tm_options = function(crs, facet.max, facet.flip, free.scales, raster.max_cells, main.title.fontface = NULL, main.title.fontfamily = NULL, main.title.position = NULL, - view.legend.position = NULL, style, ...) { args_called = names(rlang::call_match()[-1]) @@ -30,11 +29,28 @@ tm_options = function(crs, facet.max, facet.flip, free.scales, raster.max_cells, args$scale = NULL } - if (!is.null(view.legend.position)) { + if ("view.legend.position" %in% args_called) { args$legend.position = args$view.legend.position args$legend.position = NULL v3_opt(fun, "view.legend.position", "legend.position") } + if ("set.bounds" %in% args_called) { + args$set_bounds = args$set.bounds + args$set.bounds = NULL + v3_opt(fun, "set.bounds", "set_bounds") + } + if ("set.view" %in% args_called) { + args$set_view = args$set.view + args$set.view = NULL + v3_opt(fun, "set.view", "set_view") + } + if ("set.zoom.limits" %in% args_called) { + args$set_zoom_limits = args$set.zoom.limits + args$set.zoom.limits = NULL + v3_opt(fun, "set.zoom.limits", "set_zoom_limits") + } + + if (!is.null(args$title) || (!is.null(args$main.title))) { title1 = if (!is.null(args$title)) { diff --git a/R/tm_shape.R b/R/tm_shape.R index 0f062dad..ad29c689 100644 --- a/R/tm_shape.R +++ b/R/tm_shape.R @@ -53,7 +53,7 @@ tm_shape = function(shp, bbox_list = c(list(x = bbox), args[intersect(args_called, c("ext", "cx", "cy", "width", "height", "xlim", "ylim", "relative", "asp.limit"))]) if (missing(shp)) { - do.call(tm_options, args[intersect(args_called, c("bbox", "crs", "set.bounds", "set.view", "set.zoom.limits"))]) + do.call(tm_options, args[intersect(args_called, c("bbox", "crs", "set_bounds", "set_view", "set_zoom_limits"))]) } else { tm_element_list(tm_element(shp = shp, is.main = is.main, diff --git a/R/tmapLeafletAux.R b/R/tmapLeafletAux.R index e5db67a8..56f2037d 100644 --- a/R/tmapLeafletAux.R +++ b/R/tmapLeafletAux.R @@ -18,7 +18,7 @@ tmapLeafletTiles = function(bi, bbx, facet_row, facet_col, facet_page, id, pane, } else { opt = leaflet::tileOptions(maxNativeZoom = tiles$max.native.zoom, pane = pane) } - if (!is.na(o$set.zoom.limits[2])) opt$maxZoom = o$set.zoom.limits[2] + if (!is.na(o$set_zoom_limits[2])) opt$maxZoom = o$set_zoom_limits[2] for (s in tiles$server) lf = leaflet::addProviderTiles(lf, provider = s, group = s, options = opt) diff --git a/R/tmapLeafletInit.R b/R/tmapLeafletInit.R index 9cf63774..27af44eb 100644 --- a/R/tmapLeafletInit.R +++ b/R/tmapLeafletInit.R @@ -14,12 +14,12 @@ tmapLeafletInit = function(o, return.asp = FALSE, vp, prx, lf = NULL, ...) { # leaflet options if (o$crs_leaflet$crsClass == "L.CRS.Simple") { - if (is.na(o$set.zoom.limits)[1]) o$set.zoom.limits[1] = -1000 + if (is.na(o$set_zoom_limits)[1]) o$set_zoom_limits[1] = -1000 } leaflet_opts = do.call(leaflet::leafletOptions, c(list(crs=o$crs_leaflet), o$leaflet.options)) - if (!is.na(o$set.zoom.limits[1])) leaflet_opts$minZoom = o$set.zoom.limits[1] - if (!is.na(o$set.zoom.limits[2])) leaflet_opts$maxZoom = o$set.zoom.limits[2] + if (!is.na(o$set_zoom_limits[1])) leaflet_opts$minZoom = o$set_zoom_limits[1] + if (!is.na(o$set_zoom_limits[2])) leaflet_opts$maxZoom = o$set_zoom_limits[2] leaflet_opts$attributionControl = TRUE @@ -118,16 +118,16 @@ tmapLeafletAux = function(o, q) { view_set_bounds = function(lf, bbx, o) { - if (!is.logical(o$set.bounds)) { - lims = unname(o$set.bounds) + if (!is.logical(o$set_bounds)) { + lims = unname(o$set_bounds) } else { lims = unname(bbx) } - if (!(identical(o$set.bounds, FALSE))) { + if (!(identical(o$set_bounds, FALSE))) { lf = lf %>% leaflet::setMaxBounds(lims[1], lims[2], lims[3],lims[4]) } - if (is.na(o$set.view[1])) { + if (is.na(o$set_view[1])) { # check if zoom is used from tm_basemap, and if so, use that zm = NA @@ -140,21 +140,21 @@ view_set_bounds = function(lf, bbx, o) { } if (!is.na(zm)) { - set.view = c(mean.default(lims[c(1,3)]), mean.default(lims[c(2,4)]), zm) - } else if (!is.na(o$set.zoom.limits[2])) { # 2nd is checked to bypass (-1000, NA) used for simple CRS - set.view = c(mean.default(lims[c(1,3)]), mean.default(lims[c(2,4)]), o$set.zoom.limits[1]) + set_view = c(mean.default(lims[c(1,3)]), mean.default(lims[c(2,4)]), zm) + } else if (!is.na(o$set_zoom_limits[2])) { # 2nd is checked to bypass (-1000, NA) used for simple CRS + set_view = c(mean.default(lims[c(1,3)]), mean.default(lims[c(2,4)]), o$set_zoom_limits[1]) } else { - set.view = NULL + set_view = NULL } - } else if (length(o$set.view) == 1) { - set.view = c(mean.default(lims[c(1,3)]), mean.default(lims[c(2,4)]), o$set.view) + } else if (length(o$set_view) == 1) { + set_view = c(mean.default(lims[c(1,3)]), mean.default(lims[c(2,4)]), o$set_view) } else { - set.view = o$set.view + set_view = o$set_view } - if (!is.null(set.view)) { - names(set.view) = NULL - lf = lf %>% setView(set.view[1], set.view[2], set.view[3]) + if (!is.null(set_view)) { + names(set_view) = NULL + lf = lf %>% setView(set_view[1], set_view[2], set_view[3]) } if (!is.null(o$center)) lf = lf %>% addMarkers(o$center$lon, o$center$lat, label = o$center$query) diff --git a/R/tmapLeaflet_layers.R b/R/tmapLeaflet_layers.R index d81357a0..e89339b8 100644 --- a/R/tmapLeaflet_layers.R +++ b/R/tmapLeaflet_layers.R @@ -21,9 +21,11 @@ submit_labels = function(labels, cls, pane, group) { labels } -impute_webgl = function(use.WebGL, dt, supported, checkif = NULL) { - if (!identical(use.WebGL, FALSE)) { - vary = vapply(dt, function(x)any(x!=x[1]), FUN.VALUE = logical(1)) +impute_webgl = function(use_WebGL, dt, supported, checkif = NULL, type, hover, popup) { + if (!identical(use_WebGL, FALSE)) { + vary = vapply(dt, function(x) { + any(is.na(x)) || any(x!=x[1]) + }, FUN.VALUE = logical(1)) vary = vary[setdiff(names(vary), c(supported, "tmapID__", "ord__"))] @@ -36,14 +38,14 @@ impute_webgl = function(use.WebGL, dt, supported, checkif = NULL) { } if (any(vary)) { - if (is.na(use.WebGL)) { - use.WebGL = FALSE + if (is.na(use_WebGL)) { + use_WebGL = FALSE } else { - warning("WegGL enabled, but the only supported visual variables are: ", paste(supported, collapse = ", "), ". The visual variable(s) ", paste(names(vary)[vary], collapse = ", "), " are not supported. Set use.WebGL to FALSE to support them.", call. = FALSE) + message_webgl_vars(supported, vary) } } else if (any(!checks)) { - if (is.na(use.WebGL)) { - use.WebGL = FALSE + if (is.na(use_WebGL)) { + use_WebGL = FALSE } else { checkif = lapply(checkif, function(x) { if (is.character(x)) paste0("\"", x, "\"") else x @@ -58,14 +60,21 @@ impute_webgl = function(use.WebGL, dt, supported, checkif = NULL) { } }) - warning("WegGL enabled, but the following visual variable only accept one value ", paste(paste(names(checkif)[!checks], checkif[!checks], sep = " = "), collapse = ", "), ". Set use.WebGL to FALSE to support them.", call. = FALSE) + message_webgl_checks(checks, checkif) + } - } else { + } else if (type != "symbols" && hover) { + if (!is.na(use_WebGL)) { + message_webgl_hover(type) + } else { + use_WebGL = FALSE + } + } else if ((is.na(use_WebGL))) { n = nrow(dt) - use.WebGL = (n >= 500) + use_WebGL = (n >= 500) } } - use.WebGL + use_WebGL } @@ -98,6 +107,13 @@ tmapLeafletPolygons = function(shpTM, dt, pdt, popup.format, hdt, idt, gp, bbx, shp = res$shp dt = res$dt + if (!is.null(idt)) { + idt = idt$id[match(dt$tmapID__, idt$tmapID__)] + } + if (!is.null(hdt)) { + hdt = hdt$hover[match(dt$tmapID__, hdt$tmapID__)] + } + if (is.null(pdt)) { popups = NULL } else { @@ -115,9 +131,9 @@ tmapLeafletPolygons = function(shpTM, dt, pdt, popup.format, hdt, idt, gp, bbx, submit_labels("polygons", pane, group) - o$use.WebGL = impute_webgl(o$use.WebGL, dt, supported = c("fill", "col"), checkif = list(lty = "solid")) + o$use_WebGL = impute_webgl(o$use_WebGL, dt, supported = c("fill", "col"), checkif = list(lty = "solid"), type = "polygons", hover = !is.null(hdt), popup = !is.null(pdt)) - if (o$use.WebGL) { + if (o$use_WebGL) { shp2 = sf::st_sf(id = seq_along(shp), geom = shp) shp3 = suppressWarnings(sf::st_cast(shp2, "POLYGON")) shp3lines = suppressWarnings(sf::st_cast(shp3, "LINESTRING")) @@ -128,7 +144,7 @@ tmapLeafletPolygons = function(shpTM, dt, pdt, popup.format, hdt, idt, gp, bbx, fill_alpha = split_alpha_channel(gp3$fill[1], alpha = gp3$fill_alpha[1])$opacity lf |> - leafgl::addGlPolygons(data = shp3, layerId = idt, + leafgl::addGlPolygons(data = shp3, layerId = idt, label = hdt, fillColor = gp3$fill, fillOpacity = fill_alpha, group = group, pane = pane, popup = popups2) %>% {if (gp3$lwd[1]!=0 && gp3$col[1] != "#00000000") leafgl::addGlPolylines(., data = shp3lines, color = gp3$col, opacity = gp3$col_alpha[1], weight = gp3$lwd[1]/4, pane = pane, group = group, layerId = idt) else .} %>% @@ -169,11 +185,18 @@ tmapLeafletLines = function(shpTM, dt, pdt, popup.format, hdt, idt, gp, bbx, fac rc_text = frc(facet_row, facet_col) - res = select_sf(shpTM, dt) + res = select_sf(shpTM, dt[!is.na(dt$lwd), ]) shp = res$shp names(shp) = NULL # also required for other layers? dt = res$dt + if (!is.null(idt)) { + idt = idt$id[match(dt$tmapID__, idt$tmapID__)] + } + if (!is.null(hdt)) { + hdt = hdt$hover[match(dt$tmapID__, hdt$tmapID__)] + } + if (is.null(pdt)) { popups = NULL } else { @@ -189,14 +212,14 @@ tmapLeafletLines = function(shpTM, dt, pdt, popup.format, hdt, idt, gp, bbx, fac idt = (if (is.null(idt))dt$tmapID__ else idt) |> submit_labels("lines", pane, group) - o$use.WebGL = impute_webgl(o$use.WebGL, dt, supported = "col", checkif = list(lty = "solid")) + o$use_WebGL = impute_webgl(o$use_WebGL, dt, supported = "col", checkif = list(lty = "solid"), type = "lines", hover = !is.null(hdt), popup = !is.null(pdt)) - if (o$use.WebGL) { + if (o$use_WebGL) { shp2 = sf::st_sf(id = seq_along(shp), geom = shp) shp3 = suppressWarnings(sf::st_cast(shp2, "LINESTRING")) gp3 = lapply(gp, function(gpi) {if (length(gpi) == 1) gpi else gpi[shp3$id]}) lf %>% - leafgl::addGlPolylines(data = shp3, color = gp3$col, opacity = gp3$col_alpha[1], weight = gp3$lwd[1]/4, pane = pane, group = group, layerId = idt) %>% + leafgl::addGlPolylines(data = shp3, color = gp3$col, opacity = gp3$col_alpha[1], weight = gp3$lwd[1]/4, pane = pane, group = group, layerId = idt, label = hdt, popup= popups) %>% assign_lf(facet_row, facet_col, facet_page) } else { @@ -232,6 +255,13 @@ tmapLeafletSymbols = function(shpTM, dt, pdt, popup.format, hdt, idt, gp, bbx, f shp = res$shp dt = res$dt + if (!is.null(idt)) { + idt = idt$id[match(dt$tmapID__, idt$tmapID__)] + } + if (!is.null(hdt)) { + hdt = hdt$hover[match(dt$tmapID__, hdt$tmapID__)] + } + if (is.null(pdt)) { popups = NULL } else { @@ -269,11 +299,11 @@ tmapLeafletSymbols = function(shpTM, dt, pdt, popup.format, hdt, idt, gp, bbx, f #po(sort(gp2$width, decreasing = T)) - o$use.WebGL = impute_webgl(o$use.WebGL, dt, supported = c("fill", "size"), checkif = list(shape = c(1,16,19,20,21))) + o$use_WebGL = impute_webgl(o$use_WebGL, dt, supported = c("fill", "size"), checkif = list(shape = c(1,16,19,20,21)), type = "symbols", hover = !is.null(hdt), popup = !is.null(pdt)) - if (o$use.WebGL) { - lf %>% leafgl::addGlPoints(sf::st_sf(shp), fillColor = gp2$fillColor, radius = gp2$width, fillOpacity = gp2$fillOpacity[1], pane = pane, group = group) %>% + if (o$use_WebGL) { + lf %>% leafgl::addGlPoints(sf::st_sf(shp), fillColor = gp2$fillColor, radius = gp2$width, fillOpacity = gp2$fillOpacity[1], pane = pane, group = group, label = hdt, popup = popups) %>% assign_lf(facet_row, facet_col, facet_page) } else { @@ -348,7 +378,7 @@ tmapLeafletSymbols = function(shpTM, dt, pdt, popup.format, hdt, idt, gp, bbx, f } - # if (o$use.WebGL) { + # if (o$use_WebGL) { # lf %>% # leafgl::addGlPoints(sf::st_sf(shp), fillColor = gp$fill, radius = gp$size*10, fillOpacity = gp$fill_alpha, color = gp$col, opacity = gp$color_alpha, weight = gp$lwd, pane = pane, group = group) %>% # assign_lf(facet_row, facet_col, facet_page) diff --git a/R/tmap_options.R b/R/tmap_options.R index 8867507b..54d4cf7b 100644 --- a/R/tmap_options.R +++ b/R/tmap_options.R @@ -287,9 +287,9 @@ #' @param panel.label.height `r .doc_opt("panel.label.height")` #' @param panel.label.rot `r .doc_opt("panel.label.rot")` #' @param bbox `r .doc_opt("bbox")` -#' @param set.bounds `r .doc_opt("set.bounds")` -#' @param set.view `r .doc_opt("set.view")` -#' @param set.zoom.limits `r .doc_opt("set.zoom.limits")` +#' @param set_bounds `r .doc_opt("set_bounds")` +#' @param set_view `r .doc_opt("set_view")` +#' @param set_zoom_limits `r .doc_opt("set_zoom_limits")` #' @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")` @@ -310,20 +310,18 @@ #' @param attr.color `r .doc_opt("attr.color")` #' @param title deprecated See [tm_title()] #' @param main.title deprecated See [tm_title()] -#' @param view.legend.position deprecated. Use `legend.position` instead. #' @param main.title.size,main.title.color,main.title.fontface,main.title.fontfamily,main.title.position deprecated. Use the `title.` options instead. #' @name tmap_options #' @rdname tmap_options #' @export -tmap_options = function(..., crs, facet.max, facet.flip, free.scales, raster.max_cells, show.messages, show.warnings, output.format, output.size, output.dpi, animation.dpi, value.const, value.na, value.null, value.blank, values.var, values.range, value.neutral, values.scale, scales.var, scale.misc.args, continuous.nclass_per_legend_break, continuous.nclasses, label.format, label.na, scale, asp, bg.color, outer.bg.color, frame, frame.lwd, frame.r, frame.double_line, outer.margins, inner.margins, inner.margins.extra, meta.margins, meta.auto_margins, between_margin, panel.margin, component.offset, component.stack_margin, grid.mark.height, xylab.height, coords.height, xlab.show, xlab.text, xlab.size, xlab.color, xlab.rotation, xlab.space, xlab.fontface, xlab.fontfamily, xlab.side, ylab.show, ylab.text, ylab.size, ylab.color, ylab.rotation, ylab.space, ylab.fontface, ylab.fontfamily, ylab.side, panel.type, panel.wrap.pos, panel.xtab.pos, unit, color.sepia_intensity, color.saturation, color_vision_deficiency_sim, text.fontface, text.fontfamily, component.position, component.autoscale, legend.show, legend.design, legend.orientation, legend.position, legend.width, legend.height, legend.stack, legend.group.frame, legend.resize_as_group, legend.reverse, legend.na.show, legend.title.color, legend.title.size, legend.title.fontface, legend.title.fontfamily, legend.xlab.color, legend.xlab.size, legend.xlab.fontface, legend.xlab.fontfamily, legend.ylab.color, legend.ylab.size, legend.ylab.fontface, legend.ylab.fontfamily, legend.text.color, legend.text.size, legend.text.fontface, legend.text.fontfamily, legend.frame, legend.frame.lwd, legend.frame.r, legend.bg.color, legend.bg.alpha, legend.only, legend.settings.standard.portrait, legend.settings.standard.landscape, chart.show, chart.plot.axis.x, chart.plot.axis.y, chart.position, chart.width, chart.height, chart.stack, chart.group.frame, chart.resize_as_group, chart.reverse, chart.na.show, chart.title.color, chart.title.size, chart.title.fontface, chart.title.fontfamily, chart.xlab.color, chart.xlab.size, chart.xlab.fontface, chart.xlab.fontfamily, chart.ylab.color, chart.ylab.size, chart.ylab.fontface, chart.ylab.fontfamily, chart.text.color, chart.text.size, chart.text.fontface, chart.text.fontfamily, chart.frame, chart.frame.lwd, chart.frame.r, chart.bg.color, chart.bg.alpha, chart.object.color, title.show, title.size, title.color, title.fontface, title.fontfamily, title.bg.color, title.bg.alpha, title.padding, title.frame, title.frame.lwd, title.frame.r, title.stack, title.position, title.width, title.group.frame, title.resize_as_group, credits.show, credits.size, credits.color, credits.fontface, credits.fontfamily, credits.bg.color, credits.bg.alpha, credits.padding, credits.frame, credits.frame.lwd, credits.frame.r, credits.stack, credits.position, credits.width, credits.height, credits.group.frame, credits.resize_as_group, compass.north, compass.type, compass.text.size, compass.size, compass.show.labels, compass.cardinal.directions, compass.text.color, compass.color.dark, compass.color.light, compass.lwd, compass.bg.color, compass.bg.alpha, compass.margins, compass.show, compass.stack, compass.position, compass.frame, compass.frame.lwd, compass.frame.r, compass.group.frame, compass.resize_as_group, logo.height, logo.margins, logo.between_margin, logo.show, logo.stack, logo.position, logo.frame, logo.frame.lwd, logo.frame.r, logo.group.frame, logo.resize_as_group, scalebar.show, scalebar.breaks, scalebar.width, scalebar.text.size, scalebar.text.color, scalebar.color.dark, scalebar.color.light, scalebar.lwd, scalebar.bg.color, scalebar.bg.alpha, scalebar.size, scalebar.margins, scalebar.stack, scalebar.position, scalebar.frame, scalebar.frame.lwd, scalebar.frame.r, scalebar.group.frame, scalebar.resize_as_group, grid.show, grid.labels.pos, grid.x, grid.y, grid.n.x, grid.n.y, grid.crs, grid.col, grid.lwd, grid.alpha, grid.labels.show, grid.labels.size, grid.labels.col, grid.labels.rot, grid.labels.format, grid.labels.cardinal, grid.labels.margin.x, grid.labels.margin.y, grid.labels.space.x, grid.labels.space.y, grid.labels.inside_frame, grid.ticks, grid.lines, grid.ndiscr, mouse_coordinates.stack, mouse_coordinates.position, mouse_coordinates.show, minimap.server, minimap.toggle, minimap.stack, minimap.position, minimap.show, panel.show, panel.labels, panel.label.size, panel.label.color, panel.label.fontface, panel.label.fontfamily, panel.label.bg.color, panel.label.frame, panel.label.frame.lwd, panel.label.frame.r, panel.label.height, panel.label.rot, bbox, set.bounds, set.view, set.zoom.limits, qtm.scalebar, qtm.minimap, qtm.mouse_coordinates, earth_boundary, earth_boundary.color, earth_boundary.lwd, earth_datum, space.color, check_and_fix, basemap.show, basemap.server, basemap.alpha, basemap.zoom, tiles.show, tiles.server, tiles.alpha, tiles.zoom, attr.color, +tmap_options = function(..., crs, facet.max, facet.flip, free.scales, raster.max_cells, show.messages, show.warnings, output.format, output.size, output.dpi, animation.dpi, value.const, value.na, value.null, value.blank, values.var, values.range, value.neutral, values.scale, scales.var, scale.misc.args, continuous.nclass_per_legend_break, continuous.nclasses, label.format, label.na, scale, asp, bg.color, outer.bg.color, frame, frame.lwd, frame.r, frame.double_line, outer.margins, inner.margins, inner.margins.extra, meta.margins, meta.auto_margins, between_margin, panel.margin, component.offset, component.stack_margin, grid.mark.height, xylab.height, coords.height, xlab.show, xlab.text, xlab.size, xlab.color, xlab.rotation, xlab.space, xlab.fontface, xlab.fontfamily, xlab.side, ylab.show, ylab.text, ylab.size, ylab.color, ylab.rotation, ylab.space, ylab.fontface, ylab.fontfamily, ylab.side, panel.type, panel.wrap.pos, panel.xtab.pos, unit, color.sepia_intensity, color.saturation, color_vision_deficiency_sim, text.fontface, text.fontfamily, component.position, component.autoscale, legend.show, legend.design, legend.orientation, legend.position, legend.width, legend.height, legend.stack, legend.group.frame, legend.resize_as_group, legend.reverse, legend.na.show, legend.title.color, legend.title.size, legend.title.fontface, legend.title.fontfamily, legend.xlab.color, legend.xlab.size, legend.xlab.fontface, legend.xlab.fontfamily, legend.ylab.color, legend.ylab.size, legend.ylab.fontface, legend.ylab.fontfamily, legend.text.color, legend.text.size, legend.text.fontface, legend.text.fontfamily, legend.frame, legend.frame.lwd, legend.frame.r, legend.bg.color, legend.bg.alpha, legend.only, legend.settings.standard.portrait, legend.settings.standard.landscape, chart.show, chart.plot.axis.x, chart.plot.axis.y, chart.position, chart.width, chart.height, chart.stack, chart.group.frame, chart.resize_as_group, chart.reverse, chart.na.show, chart.title.color, chart.title.size, chart.title.fontface, chart.title.fontfamily, chart.xlab.color, chart.xlab.size, chart.xlab.fontface, chart.xlab.fontfamily, chart.ylab.color, chart.ylab.size, chart.ylab.fontface, chart.ylab.fontfamily, chart.text.color, chart.text.size, chart.text.fontface, chart.text.fontfamily, chart.frame, chart.frame.lwd, chart.frame.r, chart.bg.color, chart.bg.alpha, chart.object.color, title.show, title.size, title.color, title.fontface, title.fontfamily, title.bg.color, title.bg.alpha, title.padding, title.frame, title.frame.lwd, title.frame.r, title.stack, title.position, title.width, title.group.frame, title.resize_as_group, credits.show, credits.size, credits.color, credits.fontface, credits.fontfamily, credits.bg.color, credits.bg.alpha, credits.padding, credits.frame, credits.frame.lwd, credits.frame.r, credits.stack, credits.position, credits.width, credits.height, credits.group.frame, credits.resize_as_group, compass.north, compass.type, compass.text.size, compass.size, compass.show.labels, compass.cardinal.directions, compass.text.color, compass.color.dark, compass.color.light, compass.lwd, compass.bg.color, compass.bg.alpha, compass.margins, compass.show, compass.stack, compass.position, compass.frame, compass.frame.lwd, compass.frame.r, compass.group.frame, compass.resize_as_group, logo.height, logo.margins, logo.between_margin, logo.show, logo.stack, logo.position, logo.frame, logo.frame.lwd, logo.frame.r, logo.group.frame, logo.resize_as_group, scalebar.show, scalebar.breaks, scalebar.width, scalebar.text.size, scalebar.text.color, scalebar.color.dark, scalebar.color.light, scalebar.lwd, scalebar.bg.color, scalebar.bg.alpha, scalebar.size, scalebar.margins, scalebar.stack, scalebar.position, scalebar.frame, scalebar.frame.lwd, scalebar.frame.r, scalebar.group.frame, scalebar.resize_as_group, grid.show, grid.labels.pos, grid.x, grid.y, grid.n.x, grid.n.y, grid.crs, grid.col, grid.lwd, grid.alpha, grid.labels.show, grid.labels.size, grid.labels.col, grid.labels.rot, grid.labels.format, grid.labels.cardinal, grid.labels.margin.x, grid.labels.margin.y, grid.labels.space.x, grid.labels.space.y, grid.labels.inside_frame, grid.ticks, grid.lines, grid.ndiscr, mouse_coordinates.stack, mouse_coordinates.position, mouse_coordinates.show, minimap.server, minimap.toggle, minimap.stack, minimap.position, minimap.show, panel.show, panel.labels, panel.label.size, panel.label.color, panel.label.fontface, panel.label.fontfamily, panel.label.bg.color, panel.label.frame, panel.label.frame.lwd, panel.label.frame.r, panel.label.height, panel.label.rot, bbox, set_bounds, set_view, set_zoom_limits, qtm.scalebar, qtm.minimap, qtm.mouse_coordinates, earth_boundary, earth_boundary.color, earth_boundary.lwd, earth_datum, space.color, check_and_fix, basemap.show, basemap.server, basemap.alpha, basemap.zoom, tiles.show, tiles.server, tiles.alpha, tiles.zoom, attr.color, title = NULL, main.title = NULL, main.title.size = NULL, main.title.color = NULL, main.title.fontface = NULL, main.title.fontfamily = NULL, - main.title.position = NULL, - view.legend.position = NULL) { + main.title.position = NULL) { o = get("tmapOptions", envir = .TMAP) nms = names(o) show.warnings = o$show.warnings diff --git a/R/tmap_options_defaults.R b/R/tmap_options_defaults.R index 4dfc3b49..cb4ae81c 100644 --- a/R/tmap_options_defaults.R +++ b/R/tmap_options_defaults.R @@ -7,7 +7,7 @@ use.gradient = FALSE, crs = "auto"), view = list(name = "Leaflet", - use.WebGL = NA, + use_WebGL = NA, legend.position = tm_pos_in(pos.h = "right", pos.v = "bottom", align.h = "left", align.v = "top", just.h = "left", just.v = "bottom"), crs = list(dimensions = 3857, 4326), facet.max = 16, @@ -17,9 +17,9 @@ control.collapse = TRUE, panel.show = FALSE, basemap.show = TRUE, - set.bounds = FALSE, - set.view = NA, - set.zoom.limits = NA, + set_bounds = FALSE, + set_view = NA, + set_zoom_limits = NA, qtm.scalebar = TRUE, qtm.minimap = FALSE, qtm.mouse_coordinates = TRUE, @@ -578,9 +578,9 @@ # bbox = NULL, - set.bounds = FALSE, - set.view = NA, - set.zoom.limits = NA, + set_bounds = FALSE, + set_view = NA, + set_zoom_limits = NA, qtm.scalebar = FALSE, qtm.minimap = FALSE, diff --git a/data-raw/World2.R b/data-raw/World2.R index eac974f4..4d31929d 100644 --- a/data-raw/World2.R +++ b/data-raw/World2.R @@ -155,7 +155,7 @@ income_inequality = WDI(indicator = "SI.POV.GINI") |> dplyr::filter(year == max(year)) |> ungroup() |> transmute(a3 = iso3c, - income_inequality = SI.POV.GINI) + inequality = SI.POV.GINI) ################## ## gender inequality @@ -177,7 +177,7 @@ gender_inequality = df |> dplyr::filter(Year == max(Year)) |> ungroup() |> transmute(a3 = Code, - gender_inequality = gii) + gender = gii) ################## ## press freedom @@ -191,7 +191,7 @@ rsf_source <- read_csv2(tmpfile) rsf = rsf_source |> transmute(a3 = ISO, - press_freedom = Score) + press = Score) @@ -213,44 +213,52 @@ W4 <- W3 %>% rename(iso_a3 = a3) |> dplyr::select(iso_a3, name, sovereignt, continent, area, pop_est, pop_est_dens, economy, income_grp, gdp_cap_est, life_exp, well_being, footprint, HPI, - income_inequality, gender_inequality, press_freedom, geometry) %>% + inequality, gender, press, geometry) %>% mutate(sovereignt = factor(sovereignt), continent = factor(continent), economy = factor(economy), income_grp = factor(income_grp)) |> arrange(name) -World = W4 -save(World, file="data/World.rda", compress="xz") # checking data join results: -tm_shape(World) + +tm_shape(W4) + tm_polygons("HPI", fill.scale = tm_scale_intervals(values = "rd_yl_gn")) + +tm_shape(W4) + + tm_polygons("HPI", fill.scale = tm_scale_intervals(values = "classic_orange_white_blue_light", value.na = "#000000"),id= "name", hover=FALSE) + + # compare with interactive map: https://happyplanetindex.org/countries/ # missings: -World[is.na(World$HPI), ] +W4[is.na(W4$HPI), ] -tm_shape(World) + +tm_shape(W4) + tm_polygons("gender_inequality", fill.scale = tm_scale_intervals(breaks = seq(0,1,by =.1), values = "yl_or_rd")) -# compare with https://ourworldindata.org/grapher/gender-inequality-index-from-the-human-development-report +# compare with https://ourW4indata.org/grapher/gender-inequality-index-from-the-human-development-report # missings -World[is.na(World$gender_inequality), ] +W4[is.na(W4$gender_inequality), ] -tm_shape(World) + +tm_shape(W4) + tm_polygons("income_inequality") # missings -World[is.na(World$income_inequality), ] +W4[is.na(W4$income_inequality), ] -tm_shape(World) + +tm_shape(W4) + tm_polygons("press_freedom") # missings -World[is.na(World$press_freedom), ] +W4[is.na(W4$press_freedom), ] + + + +World = W4 +save(World, file="data/World.rda", compress="xz") diff --git a/examples/tm_symbols.R b/examples/tm_symbols.R index b086e716..374c40df 100644 --- a/examples/tm_symbols.R +++ b/examples/tm_symbols.R @@ -47,7 +47,7 @@ tm_shape(land) + tm_symbols(shape=airplane, size="natlscale", legend.size.show = FALSE, scale=1, border.col = NULL, id="name", popup.vars = TRUE) - #tm_view(set.view = c(lon = 15, lat = 48, zoom = 4)) + #tm_view(set_view = c(lon = 15, lat = 48, zoom = 4)) tmap_mode(current.mode) } } diff --git a/man/tm_layout.Rd b/man/tm_layout.Rd index 58e5390b..6640703a 100644 --- a/man/tm_layout.Rd +++ b/man/tm_layout.Rd @@ -257,9 +257,9 @@ tm_layout( panel.label.height, panel.label.rot, bbox, - set.bounds, - set.view, - set.zoom.limits, + set_bounds, + set_view, + set_zoom_limits, qtm.scalebar, qtm.minimap, qtm.mouse_coordinates, @@ -782,11 +782,11 @@ adjusted to the size of the device divided by the number of columns and rows.} \item{bbox}{The bounding box of the .} -\item{set.bounds}{The bounds of the set.} +\item{set_bounds}{The set_bounds of the .} -\item{set.view}{The view of the set.} +\item{set_view}{The set_view of the .} -\item{set.zoom.limits}{The limits of the zoom of the set.} +\item{set_zoom_limits}{The set_zoom_limits of the .} \item{qtm.scalebar}{The scalebar of the qtm.} diff --git a/man/tm_options.Rd b/man/tm_options.Rd index 66d645b6..1f7af431 100644 --- a/man/tm_options.Rd +++ b/man/tm_options.Rd @@ -276,9 +276,9 @@ tm_options( panel.label.height, panel.label.rot, bbox, - set.bounds, - set.view, - set.zoom.limits, + set_bounds, + set_view, + set_zoom_limits, qtm.scalebar, qtm.minimap, qtm.mouse_coordinates, @@ -304,7 +304,6 @@ tm_options( main.title.fontface = NULL, main.title.fontfamily = NULL, main.title.position = NULL, - view.legend.position = NULL, style, ... ) @@ -853,11 +852,11 @@ adjusted to the size of the device divided by the number of columns and rows.} \item{bbox}{The bounding box of the .} -\item{set.bounds}{The bounds of the set.} +\item{set_bounds}{The set_bounds of the .} -\item{set.view}{The view of the set.} +\item{set_view}{The set_view of the .} -\item{set.zoom.limits}{The limits of the zoom of the set.} +\item{set_zoom_limits}{The set_zoom_limits of the .} \item{qtm.scalebar}{The scalebar of the qtm.} @@ -901,8 +900,6 @@ adjusted to the size of the device divided by the number of columns and rows.} \item{main.title.size, main.title.color, main.title.fontface, main.title.fontfamily, main.title.position}{deprecated. Use the \code{title.} options instead.} -\item{view.legend.position}{deprecated. Use \code{legend.position} instead.} - \item{style}{style see \code{tm_style()}} \item{...}{List of tmap options to be set, or option names (characters) to be returned (see details)} diff --git a/man/tm_symbols.Rd b/man/tm_symbols.Rd index 746fb7ca..40573829 100644 --- a/man/tm_symbols.Rd +++ b/man/tm_symbols.Rd @@ -483,7 +483,7 @@ tm_shape(land) + tm_symbols(shape=airplane, size="natlscale", legend.size.show = FALSE, scale=1, border.col = NULL, id="name", popup.vars = TRUE) - #tm_view(set.view = c(lon = 15, lat = 48, zoom = 4)) + #tm_view(set_view = c(lon = 15, lat = 48, zoom = 4)) tmap_mode(current.mode) } } diff --git a/man/tm_view.Rd b/man/tm_view.Rd index 70fac8c2..e2491006 100644 --- a/man/tm_view.Rd +++ b/man/tm_view.Rd @@ -5,19 +5,19 @@ \title{View mode options} \usage{ tm_view( - use.WebGL, + use_WebGL, control.position, control.bases, control.overlays, - set.bounds, - set.view, - set.zoom.limits, + set_bounds, + set_view, + set_zoom_limits, leaflet.options, - view.legend.position = NULL + ... ) } \arguments{ -\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{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} @@ -25,22 +25,22 @@ tm_view( \item{control.overlays}{overlay layers} -\item{set.bounds}{logical that determines whether maximum bounds are set, +\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()}} -\item{set.view}{numeric vector that determines the view. +\item{set_view}{numeric vector that determines the view. Either a vector of three: \code{lng}, \code{lat}, and \code{zoom}, or a single value: \code{zoom}. See \link[leaflet:map-methods]{setView()}. Only applicable if \code{bbox} is not specified} -\item{set.zoom.limits}{numeric vector of two that set the minimum and maximum +\item{set_zoom_limits}{numeric vector of two that set the minimum and maximum zoom levels (see \link[leaflet:map-options]{tileOptions()}).} \item{leaflet.options}{options passed on to \link[leaflet:leaflet]{leafletOptions()}} -\item{view.legend.position}{deprecated. Use \code{legend.position}from \code{tm_layout()} instead.} +\item{...}{to catch deprecated arguments} } \description{ View mode options. These options are specific to the view mode. diff --git a/man/tmap_options.Rd b/man/tmap_options.Rd index 1644084f..84fa15c7 100644 --- a/man/tmap_options.Rd +++ b/man/tmap_options.Rd @@ -284,9 +284,9 @@ tmap_options( panel.label.height, panel.label.rot, bbox, - set.bounds, - set.view, - set.zoom.limits, + set_bounds, + set_view, + set_zoom_limits, qtm.scalebar, qtm.minimap, qtm.mouse_coordinates, @@ -311,8 +311,7 @@ tmap_options( main.title.color = NULL, main.title.fontface = NULL, main.title.fontfamily = NULL, - main.title.position = NULL, - view.legend.position = NULL + main.title.position = NULL ) tmap_options_mode(mode = NA, default.options = FALSE) @@ -869,11 +868,11 @@ adjusted to the size of the device divided by the number of columns and rows.} \item{bbox}{The bounding box of the .} -\item{set.bounds}{The bounds of the set.} +\item{set_bounds}{The set_bounds of the .} -\item{set.view}{The view of the set.} +\item{set_view}{The set_view of the .} -\item{set.zoom.limits}{The limits of the zoom of the set.} +\item{set_zoom_limits}{The set_zoom_limits of the .} \item{qtm.scalebar}{The scalebar of the qtm.} @@ -917,8 +916,6 @@ adjusted to the size of the device divided by the number of columns and rows.} \item{main.title.size, main.title.color, main.title.fontface, main.title.fontfamily, main.title.position}{deprecated. Use the \code{title.} options instead.} -\item{view.legend.position}{deprecated. Use \code{legend.position} instead.} - \item{mode}{mode, e.g. \code{"plot"} or \code{"view"}} \item{default.options}{return the default options or the current options?}