Repository navigation
Description
Since 25 September 2026, CARTO serves its raster basemaps (positron, dark_matter, voyager) at basemaps.cartocdn.com only to requests carrying a (free) API key: https://carto.com/basemaps/apikey/. Without a key, every tile comes back as a placeholder image reading "API KEY REQUIRED", so folium maps built with the built-in CartoDB tilesets now render as a grey watermark grid.
This was handled upstream in xyzservices: the CartoDB providers now carry an {apikey} placeholder, and build_url() strips ?key= and emits a UserWarning when no key is given (geopandas/xyzservices#207, geopandas/xyzservices#208, geopandas/xyzservices#209). folium inherits that behaviour through TileLayer, so today users get a warning plus a watermarked map, with no folium-level guidance. Note that xyzservices deliberately chose warn-and-watermark over raising (#209), so maps keep working, just with ugly tiles.
What is affected in folium
- Docs examples: built pages currently render watermarked CARTO maps. I have local changes (not yet pushed) that switch the affected examples to default tiles and document the key requirement on the tiles page and in getting started. One page remains:
docs/user_guide/plugins/search.mdusestiles="carto db positron"in an executed cell. - Docstrings:
folium.MapandTileLayerstill list"CartoDB Positron"/"CartoDB Voyager"as plain built-in options with no mention that they now require a key, and theMapdocstring example usestiles="cartodb positron"(as does theDualMapdocstring infolium/plugins/dual_map.py). - No key passthrough: there is no ergonomic way to use the built-in names with a key. Users must build the provider themselves,
xyzservices.providers.CartoDB.Positron(apikey="..."), or hand-write a URL. Anapikey=parameter onTileLayer, forwarded tobuild_url(), would lettiles="cartodb positron"keep working. - Warning text: the warning users see is the generic xyzservices one. folium could let it stand, or supplement it with folium-specific guidance pointing at the key registration page and the provider pattern.
- CHANGES.txt: the dependency-driven behaviour change deserves an entry.
- Tests (minor):
tests/test_raster_layers.pyasserts the keyless URL (still passes given the warn-and-strip behaviour), andtests/selenium/test_geojson_selenium.pyrenderscartodbpositronwithout a key in CI.
Open questions
- Should folium keep warn-and-watermark (no exception), or surface a clearer error/guidance of its own?
- Do we want an
apikeypassthrough onTileLayer/Map, or document the xyzservices-provider pattern as the solution? - Should the docstrings keep advertising CartoDB tilesets as built-ins without the key caveat, or list them with a note?
I'm happy to send PRs for whichever direction the team prefers.
Activity