diff --git a/DESCRIPTION b/DESCRIPTION index 21132d31..4a63b792 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -73,4 +73,4 @@ Config/testthat/edition: 3 Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.0 diff --git a/R/tm_layers_text.R b/R/tm_layers_text.R index 703b9458..8d8e84a9 100644 --- a/R/tm_layers_text.R +++ b/R/tm_layers_text.R @@ -54,7 +54,7 @@ #' (meaning only one group can be shown), `"check"` for check boxes (so multiple groups can be shown), #' and `"none"` for no control (the group cannot be (de)selected). #' @param ... to catch deprecated arguments from version < 4.0 -#' @example ./examples/tm_lines.R +#' @example ./examples/tm_text.R #' @export tm_text = function(text = tm_const(), text.scale = tm_scale(), diff --git a/R/tmapLeafletComp_leg_portrait.R b/R/tmapLeafletComp_leg_portrait.R index 8983f190..1973b263 100644 --- a/R/tmapLeafletComp_leg_portrait.R +++ b/R/tmapLeafletComp_leg_portrait.R @@ -40,6 +40,8 @@ tmapLeaflet_legend_comp = function(comp, o) { type = if ((!is.na(gp$fill[1]) && any(nchar(gp$fill) > 50)) || (!is.na(gp$fill_alpha[1]) && any(nchar(gp$fill_alpha) > 50)) || (!is.na(gp$col[1]) && any(nchar(gp$col) > 50)) || (!is.na(gp$col_alpha[1]) && any(nchar(gp$col_alpha) > 50))) { "gradient" + } else if (any(c("bgcol", "bgcol_alpha") %in% varying)) { + "none" } else { "symbols" } diff --git a/R/tmapLeafletLegend.R b/R/tmapLeafletLegend.R index 50e26155..00ea733d 100644 --- a/R/tmapLeafletLegend.R +++ b/R/tmapLeafletLegend.R @@ -104,7 +104,10 @@ tmapLeaflet_legend = function(cmp, lf, o, orientation) { legpos = leaflet_pos(cmp$position) - lf2 = if (cmp$type == "gradient") { + lf2 = if (cmp$typ == "none") { + #message("Text based legends not supported in view mode") + lf + } else if (cmp$type == "gradient") { vary = if ("fill" %in% cmp$varying) "fillColor" else "color" #vary_alpha = paste0(vary, "_alpha") diff --git a/R/tmapLeaflet_layers.R b/R/tmapLeaflet_layers.R index 8d839016..fd2386a8 100644 --- a/R/tmapLeaflet_layers.R +++ b/R/tmapLeaflet_layers.R @@ -298,7 +298,14 @@ tmapLeafletText = function(shpTM, dt, gp, bbx, facet_row, facet_col, facet_page, face_set = unique(gp$fontface) col_set = unique(gp$col) - if (length(face_set) != 1) warning("Variable fontfaces not supported by view mode") + bgcol_set = unique(gp$bgcol) + + if (any(bgcol_set != "#00000000")) { + message("Variable bgcol and bgcol_alpha not supported by view mode") + } + + + if (length(face_set) != 1) message("Variable fontfaces not supported by view mode") vary = (length(cex_set) != 1) || (length(alpha_set) != 1) || (length(face_set) != 1) || (length(col_set) != 1) @@ -353,15 +360,7 @@ tmapLeafletText = function(shpTM, dt, gp, bbx, facet_row, facet_col, facet_page, } assign_lf(lf, facet_row, facet_col, facet_page) - # 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) - # } else { - # lf |> - # leaflet::addCircleMarkers(lng = coords[, 1], lat = coords[, 2], fillColor = gp$fill, radius = gp$size*4, fillOpacity = gp$fill_alpha, color = gp$col, opacity = gp$color_alpha, weight = gp$lwd, group = group, options = opt) |> - # assign_lf(facet_row, facet_col, facet_page) - # } + NULL } diff --git a/examples/tm_text.R b/examples/tm_text.R new file mode 100644 index 00000000..9ba94ff6 --- /dev/null +++ b/examples/tm_text.R @@ -0,0 +1,12 @@ +tm_shape(World) + + tm_text(text = "name", + size = .4, + bgcol = "economy") + +tm_shape(World) + + tm_text(text = "name", + size = .4, + bgcol = "economy", + bgcol.scale = tm_scale_categorical(values = cols4all::.P$hcl$cat$set2), + bgcol_alpha = "pop_est", + bgcol_alpha.scale = tm_scale_intervals(style = "kmeans")) diff --git a/sandbox/issues.R b/sandbox/issues.R index e71745b2..b155eca3 100644 --- a/sandbox/issues.R +++ b/sandbox/issues.R @@ -483,5 +483,18 @@ tm_basemap(c("Esri.WorldShadedRelief", "Stadia.StamenTerrain")) + tm_tiles("Stadia.StamenTerrainLines") + tm_tiles("Stadia.StamenTerrainLabels") +## bgcol +tm_shape(World) + + tm_text("name", bgcol = "green") + +tm_shape(World) + + tm_text("name", bgcol = "economy") +tm_shape(World) + + tm_text(text = "name", + size = .4, + bgcol = "economy", + bgcol.scale = tm_scale_categorical(values = cols4all::.P$hcl$cat$set2), + bgcol_alpha = "pop_est", + bgcol_alpha.scale = tm_scale_intervals(style = "kmeans"))