GridLayer fails to load map tiles when `redraw` called at fractional zoom level
See original GitHub issueChecklist
- I’ve looked at the documentation to make sure the behavior isn’t documented and expected.
- I’m sure this is an issue with Leaflet, not with my app or other dependencies (Angular, Cordova, React, etc.).
- I’ve searched through the current issues to make sure this hasn’t been reported yet.
- I agree to follow the Code of Conduct that this project adheres to.
Steps to reproduce
Create a GridLayer and set the map zoom level to a fractional value, e.g. 2.5
. Call the redraw()
method on the grid layer. The layer makes requests with urls like:
<baseurl>/2.5/2/4.png
These requests fail, since the {z}
value is typically only available in integer steps. So the map fails to load.
Expected behavior
The _tileZoom
property should always be an integer value, so that the URL requested only resolves to integer values.
Current behavior
I believe the bug was introduced in this commit:
https://github.com/Leaflet/Leaflet/commit/2e8638761ca91506e3dc2b132da4c8185aab27f0
For example in _setView()
the _tileZoom
is round(zoom)
I think this line ought to be:
var tileZoom = Math.round(this._clampZoom(this._map.getZoom()));
Minimal example reproducing the issue
No response
Environment
- Leaflet version: git main branch (also present in leaflet@1.8.0 from npm)
- Browser (with version): firefox-100.0-4.fc35.x86_64 (also seen in chrome / safari)
- OS/Platform (with version): Fedora 35 Linux (also seen on mac and windows)
Issue Analytics
- State:
- Created a year ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Space between tiles on fractional zoom levels · Issue #3575
Falke-Design mentioned this issue on Oct 8. GridLayer fails to load map tiles when redraw called at fractional zoom level #8276.
Read more >Map doesn't load if using fractional zoom and 'zoomSnap'
I'm trying to create a map with fractional zooms enabled. So I've configured the map with its zoomSnap and zoomDelta properties to 0.1;...
Read more >Show fixed 100 m x 100 m grid on lowest zoom level
I am using leaflet with openstreetmap to create a fixed grid on top of the world map that consists of 100m x 100m...
Read more >Controlling Zoom and Pan | Maps JavaScript API
The gestureHandling option can also be set to none to disable gestures on the map. Note: The gestureHandling option does not apply to...
Read more >Leaflet 1.3 documentation
A value of 0 means the zoom level will not be snapped after fitBounds or a ... map needs to redraw its content...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve been using a patched leaflet with the above one line change for 4 months without problems.
As the gaps seem to be a separate issue, I will try to put together a PR for this one in the next couple of days.