Leaflet
Leaflet copied to clipboard
Map Tries to Get Fractional Level Tiles When Change Tile Url
Checklist
- [X] I've looked at the documentation to make sure the behavior isn't documented and expected.
- [X] I'm sure this is an issue with Leaflet, not with my app or other dependencies (Angular, Cordova, React, etc.).
- [X] I've searched through the current issues to make sure this hasn't been reported yet.
- [X] I agree to follow the Code of Conduct that this project adheres to.
Steps to reproduce
- Load A Map with tile layer in Leaflet with Its
zoomSnap
option set to an decimal value, such as 0.25, and Set the Map Zoom to be a non-integer value, such as 1.5
const map = L.map('map',{ zoomSnap: 0.25 }).setView([51.505, -0.09], 13.5);
const l = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
- Change the tile layer's URL to something else by using the
setUrl()
function for layersl.setUrl('http://mt0.google.com/vt/lyrs=s&x={x}&y={y}&z={z}')
- Errors pop up when the map is loading tiles that does not exist on the tile server.
Expected behavior
When using the setUrl()
function for layers, the map will load new tiles of the same integer level tiles it loaded for the old tile set.
Current behavior
When using the setUrl()
function for layers, the map tries to load new tiles of the fractional zoom level the map is currently at.
Minimal example reproducing the issue
https://plnkr.co/edit/v0dYEhnyhilUGDAk
Environment
- Leaflet version: [email protected]
- Browser (with version): Microsoft Edge 109.0.1518.140 () (64 bit)
- OS/Platform (with version): Microsoft Windows 6.3.9600 2013 Microsoft Corporation