Repository navigation
Description
Title
Esri World Imagery tiles do not display when switching layers at zoom level 15
Problem description
I am building an interactive GIS dashboard using Python, Folium, and Leaflet.
My map uses Esri World Dark Gray as the default basemap. I want Esri World Imagery to automatically appear when the user zooms to level 15 or closer, and return to the dark grayscale basemap when zooming out below level 15.
The dark grayscale basemap displays correctly. However, when the map reaches zoom level 15, the satellite imagery layer is added but the map displays gray tiles with the message "Map data not yet available" instead of satellite imagery.
I tested the Esri World Imagery REST service directly in my browser, and an individual tile successfully returned satellite imagery. This suggests the imagery service is reachable, but I may be implementing the automatic layer switching incorrectly.
Expected behavior
- Zoom levels 13–14: Display Esri World Dark Gray.
- Zoom level 15 and closer: Automatically display Esri World Imagery.
- Zoom back below level 15: Remove satellite imagery and restore Esri World Dark Gray.
- Preserve existing GIS layers, markers, city boundaries, and map title.
Current implementation
I am using a Folium TileLayer for the dark grayscale basemap and a Leaflet JavaScript MacroElement with:
L.tileLayer()map.on('zoomend')map.addLayer()map.removeLayer()
The imagery URL is:
https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}
Environment
- Python
- Folium
- Branca MacroElement
- Jinja2
- Leaflet
- Esri World Imagery REST service
- Windows 11
Help requested
Could someone help identify why the imagery tiles are not rendering when the layer is dynamically added at zoom level 15?
I would appreciate a working example of automatically switching between these two basemaps based on zoom level while preserving the existing Folium map layers.
Activity