From d206ad12f16966dd8d9d4ce3b7f790b20570f641 Mon Sep 17 00:00:00 2001 From: Matt Neilson Date: Fri, 8 Aug 2025 21:03:31 -0400 Subject: [PATCH 1/4] Open attribution links in a new tab --- R/layers.R | 4 ++-- R/legacy.R | 4 ++-- inst/examples/leaflet.R | 4 ++-- inst/examples/proj4Leaflet-PolarProjections.R | 5 ++++- inst/examples/proj4Leaflet-TMS.R | 2 +- inst/examples/proj4Leaflet.R | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/R/layers.R b/R/layers.R index fd39eda0d..505cf090c 100644 --- a/R/layers.R +++ b/R/layers.R @@ -166,8 +166,8 @@ addTiles <- function( options$attribution <- attribution if (missing(urlTemplate) && is.null(options$attribution)) options$attribution <- paste( - "© OpenStreetMap, ", - "ODbL" + "© OpenStreetMap, ", + "ODbL" ) invokeMethod(map, data, "addTiles", urlTemplate, layerId, group, options) diff --git a/R/legacy.R b/R/legacy.R index 8fdc60084..4bafcdf3f 100644 --- a/R/legacy.R +++ b/R/legacy.R @@ -100,8 +100,8 @@ leafletMap <- function( if (missing(initialTileLayer) && is.null(initialTileLayerAttribution)) initialTileLayerAttribution <- paste( - "© OpenStreetMap", - "contributors, CC-BY-SA" + "© OpenStreetMap", + "contributors, CC-BY-SA" ) shiny::addResourcePath("leaflet-legacy", system_file("legacy/www", package = "leaflet")) diff --git a/inst/examples/leaflet.R b/inst/examples/leaflet.R index 74d28ee69..172edd068 100644 --- a/inst/examples/leaflet.R +++ b/inst/examples/leaflet.R @@ -125,8 +125,8 @@ m %>% setView(-122.36075812146, 47.6759920119894, zoom = 13) %>% addGeoJSON(seat # use the Dark Matter layer from CartoDB leaflet() %>% addTiles("https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png", attribution = paste( - "© OpenStreetMap contributors", - "© CartoDB" + "© OpenStreetMap contributors", + "© CartoDB" ) ) %>% setView(-122.36, 47.67, zoom = 10) diff --git a/inst/examples/proj4Leaflet-PolarProjections.R b/inst/examples/proj4Leaflet-PolarProjections.R index daa5bfb67..1968679cb 100644 --- a/inst/examples/proj4Leaflet-PolarProjections.R +++ b/inst/examples/proj4Leaflet-PolarProjections.R @@ -124,7 +124,10 @@ leaflet(options = leafletOptions( addCircleMarkers(data = points, label = ~Name) %>% addTiles(urlTemplate = antarticaTilesURL, layerId = "antartica_tiles", - attribution = " NASA EOSDIS GIBS    View Source ", + attribution = paste( + " NASA EOSDIS GIBS   ", + " View Source " + ), options = tileOptions( tileSize = 512, subdomains = "abc", diff --git a/inst/examples/proj4Leaflet-TMS.R b/inst/examples/proj4Leaflet-TMS.R index 3589913e6..f5631c3be 100644 --- a/inst/examples/proj4Leaflet-TMS.R +++ b/inst/examples/proj4Leaflet-TMS.R @@ -38,7 +38,7 @@ leaflet(options = leafletOptions( addTiles("http://geodata.nationaalgeoregister.nl/tms/1.0.0/brtachtergrondkaart/{z}/{x}/{y}.png", options = tileOptions(tms = TRUE, errorTileUrl = "http://www.webmapper.net/theme/img/missing-tile.png"), - attribution = "Map data: Kadaster") %>% + attribution = "Map data: Kadaster") %>% addCircleMarkers(data = meuse.4326, popup = popupTable(meuse)) diff --git a/inst/examples/proj4Leaflet.R b/inst/examples/proj4Leaflet.R index ee7135243..b132508fa 100644 --- a/inst/examples/proj4Leaflet.R +++ b/inst/examples/proj4Leaflet.R @@ -30,7 +30,7 @@ leaflet( )) %>% addTiles( urlTemplate = "https://api.geosition.com/tile/osm-bright-3006/{z}/{x}/{y}.png", - attribution = "Map data © OpenStreetMap contributors, Imagery © 2013 Kartena", + attribution = "Map data © OpenStreetMap contributors, Imagery © 2013 Kartena", options = tileOptions(minZoom = 0, maxZoom = 14)) %>% setView(11.965, 57.704, 13) From 6aa7a115cb8fbb736490d3359744515ce1e0a6ce Mon Sep 17 00:00:00 2001 From: Matt Neilson Date: Fri, 8 Aug 2025 21:11:54 -0400 Subject: [PATCH 2/4] updated NEWS.md --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index d19b8f52f..1be87d02f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # leaflet (development version) +* Attribution links for OpenStreetMap, OpenDataCommons, CartoDB, NASA, Kadaster, Kartena will now open in a new tab (using the HTML `target` attribute) + * `{leaflet}` no longer install sp by default and attempts to convert object to sf internally before creating a map and warns when it fails conversion (@olivroy, #942). * The `breweries91`, `atlStorms2005`, and `gadmCHE` datasets are now `{sf}` objects (@olivroy, #944). From 4350d5f260afcc5ac0614eb121562f57a085f049 Mon Sep 17 00:00:00 2001 From: Matt Neilson Date: Fri, 8 Aug 2025 21:13:07 -0400 Subject: [PATCH 3/4] add target attribute for Mapbox link --- inst/legacy/examples/population/ui.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/legacy/examples/population/ui.R b/inst/legacy/examples/population/ui.R index 482a9a047..f2dc113ee 100644 --- a/inst/legacy/examples/population/ui.R +++ b/inst/legacy/examples/population/ui.R @@ -6,7 +6,7 @@ shinyUI(fluidPage( leafletMap( "map", "100%", 400, initialTileLayer = "//{s}.tiles.mapbox.com/v3/jcheng.map-5ebohr46/{z}/{x}/{y}.png", - initialTileLayerAttribution = HTML("Maps by Mapbox"), + initialTileLayerAttribution = HTML("Maps by Mapbox"), options = list( center = c(37.45, -93.85), zoom = 4, From fe364d90e571b8d81044f7a4f5ee8e10d1954c3d Mon Sep 17 00:00:00 2001 From: Matt Neilson Date: Fri, 8 Aug 2025 21:15:13 -0400 Subject: [PATCH 4/4] rebuild documentation with new link attributes --- man/leaflet.Rd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/man/leaflet.Rd b/man/leaflet.Rd index e1f1f1fd2..05d498f79 100644 --- a/man/leaflet.Rd +++ b/man/leaflet.Rd @@ -251,8 +251,8 @@ m \%>\% setView(-122.36075812146, 47.6759920119894, zoom = 13) \%>\% addGeoJSON( # use the Dark Matter layer from CartoDB leaflet() \%>\% addTiles("https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png", attribution = paste( - "© OpenStreetMap contributors", - "© CartoDB" + "© OpenStreetMap contributors", + "© CartoDB" ) ) \%>\% setView(-122.36, 47.67, zoom = 10)