leaflet icon indicating copy to clipboard operation
leaflet copied to clipboard

addProviderTiles work but Esri.OceanBasemap option suddenly does not work

Open NathanWhitmore opened this issue 2 years ago • 2 comments

Hi there. Unfortunately, the Esri.OceanBasemap tile option is no longer rendering via addProviderTiles (I've tried on my machine R version 4.2.0 and via Posit Cloud 4.2.2). Other tiles continue to render as expected. The code worked fine a few weeks ago.

This code now just renders a blank map:

library(leaflet)

leaflet() %>%
  addProviderTiles("Esri.OceanBasemap")

However, I can get the ocean basemap via the leaflet.esri package which suggests the issue may not be on the map server side.

library(leaflet)
library(leaflet.esri)

leaflet() %>%
  addEsriBasemapLayer(esriBasemapLayers$Oceans)

Any thoughts?

NathanWhitmore avatar Jan 12 '23 22:01 NathanWhitmore

The Esri.OceanBasemap got retired:

and a new endpoint created (from Ocean_Basemap to Ocean/World_Ocean_Base), which seems to be updated in leaflet-providers on Feb 10, 2023:

This line could be edited:

https://github.com/rstudio/leaflet/blob/ffd4ac8e43c882a8d1280dfc2a971f952b0e1c96/docs/libs/leaflet-providers/leaflet-providers_1.9.0.js#L423

But better to update the whole file to latest with PR. I don't have time at the moment to do this.

bbest avatar Feb 23 '23 01:02 bbest

After a bit more exploration, I discovered:

  1. The layer variant name changed from:
  • OLD: Ocean_Basemap
  • NEW: Ocean/World_Ocean_Base for surface + Ocean/World_Ocean_Reference for labels
  1. The file mentioned above leaflet-providers_1.9.0.js is only applicable to the documentation site for this R package. The htmlwidget dependency gets loaded into libs (or inline) upon rendering to html. The source for the leaflet-providers_{version}.js actually comes from the leaflet.providers R package, which can pull the latest leaflet-providers - npm via unpkg.com, eg https://unpkg.com/[email protected]/leaflet-providers.js. However, the npm package has not been updated for a year, so it doesn't reflect the latest fix for Esri.OceanBasemap at leaflet-extras/leaflet-providers: leaflet-providers.js#L472 .
  2. Until the latest leaflet-providers.js gets updated on npm, here's a reasonable workaround to manually set the proper variant while giving you the option of separately displaying Base imagery vs Reference labels and borders:
leaflet() |>
  # add base: blue bathymetry and light brown/green topography
  addProviderTiles(
    "Esri.OceanBasemap",
    options = providerTileOptions(
      variant = "Ocean/World_Ocean_Base")) |>
  # add reference: placename labels and borders
  addProviderTiles(
    "Esri.OceanBasemap",
    options = providerTileOptions(
      variant = "Ocean/World_Ocean_Reference"))

OLD: with some previously cached tiles showing up

image

NEW: with fully functional base and reference layers

image

bbest avatar Feb 23 '23 16:02 bbest