Esri / esri-leaflet

A lightweight set of tools for working with ArcGIS services in Leaflet. :rocket:
https://developers.arcgis.com/esri-leaflet/
Apache License 2.0
1.61k stars 798 forks source link

MapServer with custom LODs. initial tile set zoom level is wrong #1384

Open roocell opened 8 months ago

roocell commented 8 months ago

Describe the bug

I have a MapServer with custom zoom levels (4 to 9) which corresponds to 13 to 18 on my map. I set initial map zoom level to 13 and when I add my tile set it is requesting zoom 13 - which makes sense. But afterwards (somehow) esri-leaflet figures out that zoom 13 corresponds to 4 on my server - I assume this is in some JSON on the MapServer describing this. So when i zoom/pan after the initial load it grabs the tiles properly.

how do I get the initial tile load to use zoom 4 rather than 13?

right now, I'm just zoom/panning afterwards to get them to load.

Reproduction

var map = L.map('map').setView([45.39793819727917, -75.72070285499208], 100.0);
map.setZoom(13); // start way out (to prevent so many 404s at startup)

L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

L.esri.tiledMapLayer({
    url: "https://maps.ottawa.ca/arcgis/rest/services/Basemap_Imagery_1965/MapServer",
    pane: "overlayPane",
    opacity: 1.0, // make all hidden
    maxNativeZoom: 18, // zoom capability of tiles
    maxZoom: 22, // zoom on map (will stretch tiles)
}).addTo(map);

Logs

initial request
https://maps.ottawa.ca/arcgis/rest/services/Basemap_Imagery_1965/MapServer/tile/13/2935/2370 404 (Not Found)

successful requests after load when zoom/pan
https://maps.ottawa.ca/arcgis/rest/services/Basemap_Imagery_1965/MapServer/tile/4/2937/2371

System Info

https://unpkg.com/esri-leaflet@3.0.12/dist/esri-leaflet.js

Additional Information

No response