Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions global.R
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,21 @@ metro_theme <- bs_theme(
# because leaflet.providers 2.0.0 has no {key} slot in the CartoDB template
# (rstudio/leaflet#965), so build the tile layer by hand. The key is
# restricted by referrer in the CARTO dashboard; without it (or from a domain
# outside the allowlist) tiles come back watermarked or 403.
# outside the allowlist) tiles come back watermarked or 403. On Connect Cloud
# the key must be set as an app environment variable.

CARTO_KEY <- Sys.getenv("CARTO_BASEMAP_SHINY")

if (!nzchar(CARTO_KEY)) {
cli::cli_warn(c(
"{.envvar CARTO_BASEMAP_SHINY} is not set.",
"i" = "CARTO basemap tiles will show an API key watermark."
))
}

add_carto_tiles <- function(map, variant = "light_all") {
url <- paste0(
"https://{s}.basemaps.cartocdn.com/",
"https://basemaps.cartocdn.com/rastertiles/",
variant,
"/{z}/{x}/{y}{r}.png"
)
Expand All @@ -354,7 +362,7 @@ add_carto_tiles <- function(map, variant = "light_all") {
'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
'contributors &copy; <a href="https://carto.com/attributions">CARTO</a>'
),
options = tileOptions(subdomains = "abcd", maxZoom = 20)
options = tileOptions(maxZoom = 20)
)
return(map)
}
Expand Down
Loading