diff --git a/NAMESPACE b/NAMESPACE index 30c22434..77717aa3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,17 +1,5 @@ # Generated by roxygen2: do not edit by hand - -if(getRversion() >= "3.6.0") { - S3method(knitr::knit_print, tmap) -} else { - export(knit_print.tmap) -} - -if(getRversion() >= "3.6.0") { - S3method(knitr::knit_print, tmap_arrange) -} else { - export(knit_print.tmap_arrange) -} S3method("+",tmap) S3method(print,tm_element) S3method(print,tm_shape) @@ -210,6 +198,16 @@ export(tmap_save) export(tmap_style) export(ttm) export(ttmp) +if(getRversion() >= "3.6.0") { + S3method(knitr::knit_print, tmap) +} else { + export(knit_print.tmap) +} +if(getRversion() >= "3.6.0") { + S3method(knitr::knit_print, tmap_arrange) +} else { + export(knit_print.tmap_arrange) +} import(classInt) import(cols4all) import(data.table) @@ -235,7 +233,6 @@ importFrom(grDevices,dev.size) importFrom(grDevices,png) importFrom(grDevices,rgb) importFrom(htmlwidgets,saveWidget) -importFrom(leaflet,providers) importFrom(rlang,expr) importFrom(rlang,missing_arg) importFrom(utils,browseURL) diff --git a/R/process_meta.R b/R/process_meta.R index 3cf2528a..ff765f91 100644 --- a/R/process_meta.R +++ b/R/process_meta.R @@ -130,10 +130,11 @@ process_meta = function(o, d, cdt, aux) { o[paste0("grid.", names(a))] = a } - bbx = d$bbox[[1]] - + # add credits into to o (for view mode in order to reset default attribution text) + cid = which(vapply(cdt$comp, FUN = inherits, "tm_credits", FUN.VALUE = logical(1)))[1] + o$credits.defined = (!is.na(cid)) - + bbx = d$bbox[[1]] within(o, { # sasp shape aspect ratio (NA if free coordinates) diff --git a/R/tmapLeafletAux.R b/R/tmapLeafletAux.R index 3e6c043b..2f011ee0 100644 --- a/R/tmapLeafletAux.R +++ b/R/tmapLeafletAux.R @@ -13,7 +13,14 @@ tmapLeafletTiles = function(bi, bbx, facet_row, facet_col, facet_page, id, pane, tiles = .TMAP_LEAFLET$tiles[[id]][[bi]] - for (s in tiles$server) lf = leaflet::addProviderTiles(lf, provider = s, group = s) + if (o$credits.defined) { + opt = list(attribution = "") + } else { + opt = list() + } + + for (s in tiles$server) lf = leaflet::addProviderTiles(lf, provider = s, group = s, options = opt) + assign_lf(lf, facet_row, facet_col, facet_page) NULL } diff --git a/R/tmapLeafletComp.R b/R/tmapLeafletComp.R index 80823ee2..8637e847 100644 --- a/R/tmapLeafletComp.R +++ b/R/tmapLeafletComp.R @@ -109,6 +109,7 @@ tmapLeafletLegPlot.tm_scalebar = function(comp, lf, o) { #' @export tmapLeafletCompPrepare.tm_credits = function(comp, o) { + comp$show = TRUE comp } @@ -126,9 +127,9 @@ tmapLeafletCompWidth.tm_credits = function(comp, o) { #' @export tmapLeafletLegPlot.tm_credits = function(comp, lf, o) { - #lf %>% leafem::addLogo(system.file(paste0("img/credits_", comp$type, ".png"), package = "tmap"), src = "local", position = paste(unlist(comp$position[c("pos.v", "pos.h")]), collapse = ""), width = 120, height = 120) - message("tm_credits not implemented yet for view mode") - lf + #lf %>% leafem::addLogo(system.file(paste0("img/credits_", comp$type, ".png"), package = "tmsap"), src = "local", position = paste(unlist(comp$position[c("pos.v", "pos.h")]), collapse = ""), width = 120, height = 120) + #message("tm_credits not implemented yet for view mode") + lf %>% leaflet::addTiles(urlTemplate = "", attribution = comp$text) } diff --git a/R/tmapLeafletInit.R b/R/tmapLeafletInit.R index 4c95f2b0..a8dff2ae 100644 --- a/R/tmapLeafletInit.R +++ b/R/tmapLeafletInit.R @@ -52,7 +52,7 @@ tmapLeafletInit = function(o, return.asp = FALSE, vp) { 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 = FALSE + leaflet_opts$attributionControl = TRUE