Leaflet icon indicating copy to clipboard operation
Leaflet copied to clipboard

Map Tries to Get Fractional Level Tiles When Change Tile Url

Open ABPW10 opened this issue 7 months ago β€’ 1 comments

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

  1. 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: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
	}).addTo(map);
  1. Change the tile layer's URL to something else by using the setUrl() function for layers l.setUrl('http://mt0.google.com/vt/lyrs=s&x={x}&y={y}&z={z}')
  2. 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. image image

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

ABPW10 avatar Jul 21 '24 05:07 ABPW10