Open ABPW10 opened 2 months ago
Workaround by temporarily overriding the map's getZoom()
function :
const originalZoom=map.getZoom()
const originalGetZoom=map.getZoom
if(originalZoom%1!==0){map.getZoom=()=>Math.round(originalZoom)}
mapLyrImg.options=lyrImg.options
mapLyrImg.setUrl(lyrImg._url)
if(originalZoom%1!==0){map.getZoom=originalGetZoom;map.setZoom(originalZoom)}
Checklist
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.5setUrl()
function for layersl.setUrl('http://mt0.google.com/vt/lyrs=s&x={x}&y={y}&z={z}')
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