I am trying to use the map.geo.admin tiles in leaflet.
When running
url <- 'https://wmts20.geo.admin.ch/1.0.0/ch.swisstopo.pixelkarte-farbe/default/current/3857/{z}/{x}/{y}.jpeg'
library(leaflet)
options(viewer = NULL)
leaflet() %>%
setView(lat = 47, lng = 9, zoom = 8) %>%
addTiles(urlTemplate = url)
the map is shown correctly in the browser (it does not work in RStudio Viewer pane),
but when I put the code inside a shiny app I get only a grey map (sometimes it is initially shown, but when I start zooming it greys out):
library(shiny)
ui <- fluidPage(
leafletOutput("map")
)
server <- function(input, output, session) {
output$map <- renderLeaflet({
leaflet() %>%
setView(lat = 47, lng = 9, zoom = 8) %>%
addTiles(urlTemplate = url)
# addTiles()
})
}
shinyApp(ui, server)
you need to register your domain according https://shop.swisstopo.admin.ch/en/products/geoservice/swisstopo_geoservices/WMTS_info to https://www.geo.admin.ch/de/geo-services/geo-services/portrayal-services-web-mapping/programming-interface-api/order_form.html
othterwise you won't get access to the tiles