diff --git a/R/layers.R b/R/layers.R index 96a454497..528e7a727 100644 --- a/R/layers.R +++ b/R/layers.R @@ -123,7 +123,7 @@ hideGroup <- function(map, group) { #' addMarkers(data = quakes, group = "basic") %>% #' # When zoomed in, we'll show circles at the base of each marker whose #' # radius and color reflect the magnitude -#' addProviderTiles(providers$Stamen.TonerLite, group = "detail") %>% +#' addProviderTiles(providers$Esri.WorldTopoMap, group = "detail") %>% #' addCircleMarkers(data = quakes, group = "detail", fillOpacity = 0.5, #' radius = ~mag * 5, color = ~pal(mag), stroke = FALSE) %>% #' # Set the detail group to only appear when zoomed in @@ -1607,10 +1607,10 @@ clearGeoJSON <- function(map) { #' \donttest{ #' leaflet() %>% #' addTiles(group = "OpenStreetMap") %>% -#' addProviderTiles("Stamen.Toner", group = "Toner by Stamen") %>% +#' addProviderTiles("CartoDB.Voyager", group = "Carto Voyager") %>% #' addMarkers(runif(20, -75, -74), runif(20, 41, 42), group = "Markers") %>% #' addLayersControl( -#' baseGroups = c("OpenStreetMap", "Toner by Stamen"), +#' baseGroups = c("OpenStreetMap", "Carto Voyager"), #' overlayGroups = c("Markers") #' ) #' } diff --git a/R/plugin-providers.R b/R/plugin-providers.R index fbb769484..c17f6397f 100644 --- a/R/plugin-providers.R +++ b/R/plugin-providers.R @@ -27,8 +27,8 @@ leafletProviderDependencies <- function() { #' #' @examples #' leaflet() %>% -#' addProviderTiles("Stamen.Watercolor") %>% -#' addProviderTiles("Stamen.TonerHybrid") +#' addProviderTiles("Esri.WorldTopoMap") %>% +#' addProviderTiles("CartoDB.DarkMatter") #' #' @export addProviderTiles <- function( diff --git a/inst/examples/geojson.R b/inst/examples/geojson.R index 32cf0058b..103c24471 100644 --- a/inst/examples/geojson.R +++ b/inst/examples/geojson.R @@ -1,4 +1,3 @@ - library(leaflet) library(sp) #'

@@ -19,13 +18,16 @@ icons <- awesomeIconList( restaurant = makeAwesomeIcon(icon = "cutlery", library = "fa", markerColor = "blue") ) -leaflet() %>% addTiles() %>% +leaflet() %>% + addTiles() %>% setView(10.758276373601069, 59.92448055859924, 13) %>% - addAwesomeMarkers(data = spdf, - label = ~stringr::str_c(amenity, ": ", name), - icon = ~icons[amenity], - options = markerOptions(riseOnHover = TRUE, opacity = 0.75), - group = "pubs") + addAwesomeMarkers( + data = spdf, + label = ~ stringr::str_c(amenity, ": ", name), + icon = ~ icons[amenity], + options = markerOptions(riseOnHover = TRUE, opacity = 0.75), + group = "pubs" + ) #'

@@ -36,8 +38,13 @@ mhSPDF <- geojsonio::geojson_read(url, what = "sp") cols <- colorFactor(topo.colors(nrow(mhSPDF)), mhSPDF$NAME_2) -leaflet() %>% addProviderTiles(providers$Stamen.TonerLite) %>% +leaflet() %>% + addProviderTiles(providers$CartoDB.Voyager) %>% setView(75.7139, 19.7515, 6) %>% - addPolygons(data = mhSPDF, opacity = 5, - label = ~NAME_2, weight = 1, - fillColor = ~cols(NAME_2)) + addPolygons( + data = mhSPDF, + opacity = 5, + label = ~NAME_2, + weight = 1, + fillColor = ~ cols(NAME_2) + ) diff --git a/inst/examples/providers-shiny.R b/inst/examples/providers-shiny.R index e01edf9db..1867bb219 100644 --- a/inst/examples/providers-shiny.R +++ b/inst/examples/providers-shiny.R @@ -8,9 +8,9 @@ ui <- fluidPage( selectInput( "providerName", "Tile set", - c("Stamen.Toner", - "Stamen.TonerLite", - "Stamen.Watercolor") + c("CartoDB.Positron", + "CartoDB.Voyager", + "CartoDB.DarkMatter") ) ), column( diff --git a/man/addLayersControl.Rd b/man/addLayersControl.Rd index 2ca856fd0..67f3bd4f5 100644 --- a/man/addLayersControl.Rd +++ b/man/addLayersControl.Rd @@ -58,10 +58,10 @@ any number of overlay layers to view. \donttest{ leaflet() \%>\% addTiles(group = "OpenStreetMap") \%>\% - addProviderTiles("Stamen.Toner", group = "Toner by Stamen") \%>\% + addProviderTiles("CartoDB.Voyager", group = "Carto Voyager") \%>\% addMarkers(runif(20, -75, -74), runif(20, 41, 42), group = "Markers") \%>\% addLayersControl( - baseGroups = c("OpenStreetMap", "Toner by Stamen"), + baseGroups = c("OpenStreetMap", "Carto Voyager"), overlayGroups = c("Markers") ) } diff --git a/man/addProviderTiles.Rd b/man/addProviderTiles.Rd index 4cd231f18..2228b7c6d 100644 --- a/man/addProviderTiles.Rd +++ b/man/addProviderTiles.Rd @@ -52,7 +52,7 @@ Add a tile layer from a known map provider } \examples{ leaflet() \%>\% - addProviderTiles("Stamen.Watercolor") \%>\% - addProviderTiles("Stamen.TonerHybrid") + addProviderTiles("Esri.WorldTopoMap") \%>\% + addProviderTiles("CartoDB.DarkMatter") } diff --git a/man/groupOptions.Rd b/man/groupOptions.Rd index 69720c970..5c6ce2bdd 100644 --- a/man/groupOptions.Rd +++ b/man/groupOptions.Rd @@ -29,7 +29,7 @@ leaflet() \%>\% addMarkers(data = quakes, group = "basic") \%>\% # When zoomed in, we'll show circles at the base of each marker whose # radius and color reflect the magnitude - addProviderTiles(providers$Stamen.TonerLite, group = "detail") \%>\% + addProviderTiles(providers$Esri.WorldTopoMap, group = "detail") \%>\% addCircleMarkers(data = quakes, group = "detail", fillOpacity = 0.5, radius = ~mag * 5, color = ~pal(mag), stroke = FALSE) \%>\% # Set the detail group to only appear when zoomed in diff --git a/vignettes/articles/basemaps.Rmd b/vignettes/articles/basemaps.Rmd index 28ba7fadc..10ca8102e 100644 --- a/vignettes/articles/basemaps.Rmd +++ b/vignettes/articles/basemaps.Rmd @@ -29,13 +29,19 @@ Alternatively, many popular free third-party basemaps can be added using the `ad As a convenience, leaflet also provides a named list of all the third-party tile providers that are supported by the plugin. This enables you to use auto-completion feature of your favorite R IDE (like RStudio) and not have to remember or look up supported tile providers; just type `providers$` and choose from one of the options. You can also use `names(providers)` to view all of the options. ```{r fig.height=1.25} -m %>% addProviderTiles(providers$Stadia.StamenToner) m %>% addProviderTiles(providers$CartoDB.Positron) m %>% addProviderTiles(providers$Esri.NatGeoWorldMap) +m %>% addProviderTiles(providers$OpenTopoMap) +m %>% addProviderTiles(providers$Stadia.StamenToner) ``` Note that some tile set providers require you to register; see the [project page](https://github.com/leaflet-extras/leaflet-providers) for more information. You can pass access tokens/keys, and other options, to the tile provider by populating the `options` argument with the `providerTileOptions()` function. +As of October 2023, Stamen map tiles are now hosted by [Stadia Maps](https://stadiamaps.com/). +Replace all references to `providers$Stamen.____` with `providers$Stadia.Stamen____` to use the new tiles. +Published maps now [require an account](https://client.stadiamaps.com/signup/); once created, login and register your domain(s) where the maps will be published. + + # Custom Tile URL Template If you happen to have a custom map tile URL template to use, you can provide it as an argument to `addTiles()`. @@ -45,7 +51,9 @@ If you happen to have a custom map tile URL template to use, you can provide it You can use `addWMSTiles()` to add WMS (Web Map Service) tiles. The map below shows the Base Reflectivity (a measure of the intensity of precipitation occurring) using the WMS from the [Iowa Environmental Mesonet ](https://mesonet.agron.iastate.edu/): ```{r fig.height=2.5} -leaflet() %>% addTiles() %>% setView(-93.65, 42.0285, zoom = 4) %>% +leaflet() %>% + addTiles() %>% + setView(-93.65, 42.0285, zoom = 4) %>% addWMSTiles( "http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi", layers = "nexrad-n0r-900913", @@ -59,8 +67,10 @@ leaflet() %>% addTiles() %>% setView(-93.65, 42.0285, zoom = 4) %>% You aren't restricted to using a single basemap on a map; you can stack them by adding multiple tile layers. This generally only makes sense if the front tiles consist of semi transparent tiles, or have an adjusted opacity via the `options` argument. ```{r fig.height=1.75} -m %>% addProviderTiles(providers$MtbMap) %>% - addProviderTiles(providers$Stadia.StamenTonerLines, - options = providerTileOptions(opacity = 0.35)) %>% - addProviderTiles(providers$Stadia.StamenTonerLabels) +m %>% + addProviderTiles( + providers$Esri.WorldImagery, + options = providerTileOptions(opacity = 0.5) + ) %>% + addProviderTiles(providers$CartoDB.VoyagerOnlyLabels) ``` diff --git a/vignettes/articles/images/shiny1.png b/vignettes/articles/images/shiny1.png index 3325d6450..48571695b 100644 Binary files a/vignettes/articles/images/shiny1.png and b/vignettes/articles/images/shiny1.png differ diff --git a/vignettes/articles/shiny.Rmd b/vignettes/articles/shiny.Rmd index 0cf4ef724..e76d60113 100644 --- a/vignettes/articles/shiny.Rmd +++ b/vignettes/articles/shiny.Rmd @@ -37,7 +37,7 @@ server <- function(input, output, session) { output$mymap <- renderLeaflet({ leaflet() %>% - addProviderTiles(providers$Stadia.StamenTonerLite, + addProviderTiles(providers$CartoDB.Positron, options = providerTileOptions(noWrap = TRUE) ) %>% addMarkers(data = points()) diff --git a/vignettes/articles/showhide.Rmd b/vignettes/articles/showhide.Rmd index 9763a4f1f..00574ca5e 100644 --- a/vignettes/articles/showhide.Rmd +++ b/vignettes/articles/showhide.Rmd @@ -55,15 +55,33 @@ outline <- quakes[chull(quakes$long, quakes$lat),] map <- leaflet(quakes) %>% # Base groups addTiles(group = "OSM (default)") %>% - addProviderTiles(providers$Stadia.StamenToner, group = "Toner") %>% - addProviderTiles(providers$Stadia.StamenTonerLite, group = "Toner Lite") %>% + addProviderTiles(providers$CartoDB.Positron, group = "Positron (minimal)") %>% + addProviderTiles(providers$Esri.WorldImagery, group = "World Imagery (satellite)") %>% # Overlay groups - addCircles(~long, ~lat, ~10^mag/5, stroke = FALSE, group = "Quakes") %>% - addPolygons(data = outline, lng = ~long, lat = ~lat, - fill = FALSE, weight = 2, color = "#FFFFCC", group = "Outline") %>% + addCircles( + ~ long, + ~ lat, + ~ 10 ^ mag / 5, + stroke = FALSE, + group = "Quakes", + fillColor = "tomato" + ) %>% + addPolygons( + data = outline, + lng = ~ long, + lat = ~ lat, + fill = FALSE, + weight = 2, + color = "#FFFFCC", + group = "Outline" + ) %>% # Layers control addLayersControl( - baseGroups = c("OSM (default)", "Toner", "Toner Lite"), + baseGroups = c( + "OSM (default)", + "Positron (minimal)", + "World Imagery (satellite)" + ), overlayGroups = c("Quakes", "Outline"), options = layersControlOptions(collapsed = FALSE) )