diff --git a/NAMESPACE b/NAMESPACE index cd1bab64..1c55bab0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -73,6 +73,7 @@ S3method(tmapLeafletCompHeight,tm_compass) S3method(tmapLeafletCompHeight,tm_credits) S3method(tmapLeafletCompHeight,tm_legend_standard_landscape) S3method(tmapLeafletCompHeight,tm_legend_standard_portrait) +S3method(tmapLeafletCompHeight,tm_logo) S3method(tmapLeafletCompHeight,tm_minimap) S3method(tmapLeafletCompHeight,tm_mouse_coordinates) S3method(tmapLeafletCompHeight,tm_scalebar) @@ -83,6 +84,7 @@ S3method(tmapLeafletCompPrepare,tm_compass) S3method(tmapLeafletCompPrepare,tm_credits) S3method(tmapLeafletCompPrepare,tm_legend_standard_landscape) S3method(tmapLeafletCompPrepare,tm_legend_standard_portrait) +S3method(tmapLeafletCompPrepare,tm_logo) S3method(tmapLeafletCompPrepare,tm_minimap) S3method(tmapLeafletCompPrepare,tm_mouse_coordinates) S3method(tmapLeafletCompPrepare,tm_scalebar) @@ -92,6 +94,7 @@ S3method(tmapLeafletCompWidth,tm_compass) S3method(tmapLeafletCompWidth,tm_credits) S3method(tmapLeafletCompWidth,tm_legend_standard_landscape) S3method(tmapLeafletCompWidth,tm_legend_standard_portrait) +S3method(tmapLeafletCompWidth,tm_logo) S3method(tmapLeafletCompWidth,tm_minimap) S3method(tmapLeafletCompWidth,tm_mouse_coordinates) S3method(tmapLeafletCompWidth,tm_scalebar) @@ -102,6 +105,7 @@ S3method(tmapLeafletLegPlot,tm_compass) S3method(tmapLeafletLegPlot,tm_credits) S3method(tmapLeafletLegPlot,tm_legend_standard_landscape) S3method(tmapLeafletLegPlot,tm_legend_standard_portrait) +S3method(tmapLeafletLegPlot,tm_logo) S3method(tmapLeafletLegPlot,tm_minimap) S3method(tmapLeafletLegPlot,tm_mouse_coordinates) S3method(tmapLeafletLegPlot,tm_scalebar) diff --git a/R/tmapGridComp_funs.R b/R/tmapGridComp_funs.R index 80f993be..f62e94bd 100644 --- a/R/tmapGridComp_funs.R +++ b/R/tmapGridComp_funs.R @@ -168,7 +168,7 @@ tmapGridLegPlot.tm_compass = function(comp, o, fH, fW) { fill = c(dark, light) } else if (comp$type=="radar") { cr = c(.45, .42, .2, .17, .1) - LWD = round(convertWidth(unit(.01, "npc"), "points", valueOnly=TRUE)) * comp$lwd + LWD = (o$lineH * 24) * comp$lwd cd = seq(1/8, 15/8, by=.25) * pi cd2 = seq(1/4, 7/4, by=.5) * pi diff --git a/R/tmapLeafletComp_funs.R b/R/tmapLeafletComp_funs.R index d9c39b70..819fe098 100644 --- a/R/tmapLeafletComp_funs.R +++ b/R/tmapLeafletComp_funs.R @@ -76,7 +76,7 @@ tmapLeafletCompWidth.tm_compass = function(comp, o) { #' @export tmapLeafletLegPlot.tm_compass = function(comp, lf, o) { - lf %>% leafem::addLogo(system.file(paste0("img/compass_", comp$type, ".png"), package = "tmap"), position = leaflet_pos(comp$position), width = 120, height = 120) + lf %>% leafem::addLogo(system.file(paste0("img/compass_", comp$type, ".png"), package = "tmap"), src = "local", position = leaflet_pos(comp$position), width = 120, height = 120) } @@ -206,3 +206,34 @@ tmapLeafletLegPlot.tm_minimap = function(comp, lf, o) { lf2 } +#' @export +tmapLeafletCompPrepare.tm_logo = function(comp, o) { + comp$logo = lapply(comp$file, function(lf){ + tmap_icons(lf) + }) + comp$asp = vapply(comp$logo, function(lg) { + lg$iconWidth / lg$iconHeight + }, FUN.VALUE = numeric(1)) + comp$show = TRUE + comp +} + + +#' @export +tmapLeafletCompHeight.tm_logo = function(comp, o) { + comp +} + +#' @export +tmapLeafletCompWidth.tm_logo = function(comp, o) { + comp +} + +#' @export +tmapLeafletLegPlot.tm_logo = function(comp, lf, o) { + for (i in 1:length(comp$logo)) { + lf = lf %>% leafem::addLogo(comp$logo[[i]]$iconUrl, src = "local", position = leaflet_pos(comp$position)) + } + lf +} + diff --git a/examples/tm_logo.R b/examples/tm_logo.R index 0b503860..9f3c12b2 100644 --- a/examples/tm_logo.R +++ b/examples/tm_logo.R @@ -5,5 +5,4 @@ tm_shape(World) + tm_logo(c("https://www.r-project.org/logo/Rlogo.png", system.file("help", "figures", "logo.png", package = "tmap"))) + tm_logo("http://blog.kulikulifoods.com/wp-content/uploads/2014/10/logo.png", - height=5, position = c("left", "top")) + - tm_format("World") + height=5, position = c("left", "top")) diff --git a/man/tm_logo.Rd b/man/tm_logo.Rd index 300b0e94..93f76cbd 100644 --- a/man/tm_logo.Rd +++ b/man/tm_logo.Rd @@ -57,8 +57,7 @@ tm_shape(World) + tm_logo(c("https://www.r-project.org/logo/Rlogo.png", system.file("help", "figures", "logo.png", package = "tmap"))) + tm_logo("http://blog.kulikulifoods.com/wp-content/uploads/2014/10/logo.png", - height=5, position = c("left", "top")) + - tm_format("World") + height=5, position = c("left", "top")) } \seealso{ \href{https://r-tmap.github.io/tmap/articles/basics_components}{Vignette about components} diff --git a/man/tm_scale_intervals.Rd b/man/tm_scale_intervals.Rd index 5517bfe2..5d01f9f8 100644 --- a/man/tm_scale_intervals.Rd +++ b/man/tm_scale_intervals.Rd @@ -69,5 +69,7 @@ layer functions (e.g. \code{fill.scale} in \code{\link[=tm_polygons]{tm_polygons The function \code{tm_scale_intervals()} is used for numerical data. } \seealso{ +\href{https://r-tmap.github.io/tmap/articles/basics_scales}{tmap basics: scales} + \code{\link[=tm_scale]{tm_scale()}} } diff --git a/man/tm_seq.Rd b/man/tm_seq.Rd index 01c0c8a0..43cb32b8 100644 --- a/man/tm_seq.Rd +++ b/man/tm_seq.Rd @@ -13,7 +13,7 @@ tm_seq( \arguments{ \item{from, to}{The numeric range, default 0 and 1 respectively} -\item{power}{The power component, or one of \code{"lin"}, \code{"sqrt"}, \code{"sqrt_perceptual"}, \code{"quadratic"}, which correspond to 1, 0.5, 0.5716, 2 respectively. See details.} +\item{power}{The power component, a number or or one of \code{"lin"}, \code{"sqrt"}, \code{"sqrt_perceptual"}, \code{"quadratic"}, which correspond to 1, 0.5, 0.5716, 2 respectively. See details.} } \description{ Specify a numeric sequence, for numeric scales like \code{\link[=tm_scale_continuous]{tm_scale_continuous()}}. This function is needed when there is a non-linear relationship between the numeric data values and the visual variables. E.g. to make relationship with the area of bubbles linear, the square root of input variables should be used to calculate the radius of the bubbles.