diff --git a/R/tm_layers_lines.R b/R/tm_layers_lines.R index 51f5e663..27f057f8 100644 --- a/R/tm_layers_lines.R +++ b/R/tm_layers_lines.R @@ -48,8 +48,7 @@ opt_tm_lines = function(lines.only = "ifany") { #' @param options options passed on to the corresponding `opt_` function #' @param popup.vars names of data variables that are shown in the popups in `"view"` mode. Set popup.vars to `TRUE` to show all variables in the shape object. Set popup.vars to `FALSE` to disable popups. Set popup.vars to a character vector of variable names to those those variables in the popups. The default (`NA`) depends on whether visual variables (e.g.`col`) are used. If so, only those are shown. If not all variables in the shape object are shown. #' @param popup.format list of formatting options for the popup values. See the argument `legend.format` for options. Only applicable for numeric data variables. If one list of formatting options is provided, it is applied to all numeric variables of `popup.vars`. Also, a (named) list of lists can be provided. In that case, each list of formatting options is applied to the named variable. -#' @param hover name of the data variable that specifies the hover labels -#' +#' @param hover name of the data variable that specifies the hover labels (view mode only). Set to `FALSE` to disable hover labels. By default `FALSE`, unless `id` is specified. In that case, it is set to `id`, #' @param id name of the data variable that specifies the indices of the spatial features. Only used for `"view"` mode. #' @param lines.only should only line geometries of the shape object (defined in [tm_shape()]) be plotted, or also other geometry types (like polygons)? By default `"ifany"`, which means `TRUE` in case a geometry collection is specified. #' @param ... to catch deprecated arguments from version < 4.0 @@ -83,7 +82,7 @@ tm_lines = function(col = tm_const(), group.control = "check", popup.vars = NA, popup.format = list(), - hover = "", + hover = NA, id = "", options = opt_tm_lines(), ...) { diff --git a/R/tm_layers_polygons.R b/R/tm_layers_polygons.R index ed0206b0..26053d50 100644 --- a/R/tm_layers_polygons.R +++ b/R/tm_layers_polygons.R @@ -73,7 +73,7 @@ opt_tm_polygons = function(polygons.only = "ifany") { #' it is applied to all numeric variables of `popup.vars`. Also, a (named) #' list of lists can be provided. In that case, each list of formatting options #' is applied to the named variable. -#' @param hover name of the data variable that specifies the hover labels +#' @param hover name of the data variable that specifies the hover labels (view mode only). Set to `FALSE` to disable hover labels. By default `FALSE`, unless `id` is specified. In that case, it is set to `id`, #' @param id name of the data variable that specifies the indices of the spatial #' features. Only used for `"view"` mode. #' @param polygons.only should only polygon geometries of the shape object (defined in [tm_shape()]) be plotted? By default `"ifany"`, which means `TRUE` in case a geometry collection is specified. @@ -120,7 +120,7 @@ tm_polygons = function(fill = tm_const(), group.control = "check", popup.vars = NA, popup.format = list(), - hover = "", + hover = NA, id = "", options = opt_tm_polygons(), ...) { diff --git a/R/tm_layers_symbols.R b/R/tm_layers_symbols.R index bed11dbf..04838283 100644 --- a/R/tm_layers_symbols.R +++ b/R/tm_layers_symbols.R @@ -102,8 +102,7 @@ opt_tm_squares = opt_tm_symbols #' variables. If one list of formatting options is provided, it is applied to #' all numeric variables of `popup.vars`. Also, a (named) list of lists can be provided. #' In that case, each list of formatting options is applied to the named variable. -#' @param hover name of the data variable that specifies the hover labels -#' +#' @param hover name of the data variable that specifies the hover labels (view mode only). Set to `FALSE` to disable hover labels. By default `FALSE`, unless `id` is specified. In that case, it is set to `id`, #' @param id name of the data variable that specifies the indices of the spatial features. #' Only used for `"view"` mode. #' @param points.only should only point geometries of the shape object (defined in [tm_shape()]) be plotted? By default `"ifany"`, which means `TRUE` in case a geometry collection is specified. @@ -161,7 +160,7 @@ tm_symbols = function(size = tm_const(), group.control = "check", popup.vars = NA, popup.format = list(), - hover = "", + hover = NA, id = "", options = opt_tm_symbols(), ...) { diff --git a/R/tmapLeaflet_layers.R b/R/tmapLeaflet_layers.R index 039ed413..ae888321 100644 --- a/R/tmapLeaflet_layers.R +++ b/R/tmapLeaflet_layers.R @@ -12,8 +12,7 @@ tmapLeafletPolygons = function(shpTM, dt, pdt, popup.format, hdt, idt, gp, bbx, popups = NULL } else { pdt = pdt[match(dt$tmapID__, pdt$tmapID__)][, tmapID__ := NULL] - - popups = view_format_popups(id = hdt, titles = names(pdt), values = pdt, format = popup.format) + popups = view_format_popups(id = idt, titles = names(pdt), values = pdt, format = popup.format) } @@ -72,7 +71,7 @@ tmapLeafletLines = function(shpTM, dt, pdt, popup.format, hdt, idt, gp, bbx, fac popups = NULL } else { pdt = pdt[match(dt$tmapID__, pdt$tmapID__)][, tmapID__ := NULL] - popups = view_format_popups(id = hdt, titles = names(pdt), values = pdt, format = popup.format) + popups = view_format_popups(id = idt, titles = names(pdt), values = pdt, format = popup.format) } gp = impute_gp(gp, dt) @@ -111,7 +110,7 @@ tmapLeafletSymbols = function(shpTM, dt, pdt, popup.format, hdt, idt, gp, bbx, f } else { pdt = pdt[match(dt$tmapID__, pdt$tmapID__)][, tmapID__ := NULL] - popups = view_format_popups(id = hdt, titles = names(pdt), values = pdt, format = popup.format) + popups = view_format_popups(id = idt, titles = names(pdt), values = pdt, format = popup.format) } gp = impute_gp(gp, dt) diff --git a/R/view_format_popups.R b/R/view_format_popups.R index 0cbd4001..3992f99c 100644 --- a/R/view_format_popups.R +++ b/R/view_format_popups.R @@ -21,7 +21,6 @@ view_format_popups <- function(id=NULL, titles, format, values) { function(x) x } }) - if (!is.null(id)) { labels <- paste("", h[[1]](id), "", sep="") } else { diff --git a/R/view_functions.R b/R/view_functions.R index ad2bb5a4..d73c2964 100644 --- a/R/view_functions.R +++ b/R/view_functions.R @@ -41,21 +41,6 @@ # gpl$data[[gpl[[var_names]]]] # } -get_popups <- function(gpl, type) { - var_names <- paste(type, "names", sep=".") - var_vars <- paste(type, "popup.vars", sep=".") - var_format <- paste(type, "popup.format", sep=".") - - dt <- gpl$data - - if (is.na(gpl[[var_vars]][1])) { - popups <- NULL - } else { - popups <- view_format_popups(dt[[gpl[[var_names]]]], gpl[[var_vars]], gpl[[var_format]], dt[, gpl[[var_vars]], drop=FALSE]) - } - popups -} - # # working_internet <- function(url = "https://www.google.com") { # # test the http capabilities of the current R build