Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: replace Stamen/Stadia in vignettes, function documentation, and inst examples #913

Merged
merged 5 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions R/layers.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1608,10 +1608,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")
#' )
#' }
Expand Down
4 changes: 2 additions & 2 deletions R/plugin-providers.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ leafletProviderDependencies <- function() {
#'
#' @examples
#' leaflet() %>%
#' addProviderTiles("Stamen.Watercolor") %>%
#' addProviderTiles("Stamen.TonerHybrid")
#' addProviderTiles("Esri.WorldTopoMap") %>%
#' addProviderTiles("CartoDB.DarkMatter")
#'
#' @export
addProviderTiles <- function(
Expand Down
29 changes: 18 additions & 11 deletions inst/examples/geojson.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

library(leaflet)
library(sp)
#' <br/><br/>
Expand All @@ -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"
)


#' <br/><br/>
Expand All @@ -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)
)
6 changes: 3 additions & 3 deletions inst/examples/providers-shiny.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions man/addLayersControl.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/addProviderTiles.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/groupOptions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 16 additions & 6 deletions vignettes/articles/basemaps.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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()`.
Expand All @@ -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",
Expand All @@ -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)
```
Binary file modified vignettes/articles/images/shiny1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion vignettes/articles/shiny.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
30 changes: 24 additions & 6 deletions vignettes/articles/showhide.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down