question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GridLayer fails to load map tiles when `redraw` called at fractional zoom level

See original GitHub issue

Checklist

  • 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)

https://github.com/Leaflet/Leaflet/blob/c7d3e97d9ae3fada1f7ab047d4d56c06cec35d12/src/layer/tile/GridLayer.js#L552

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:open
  • Created a year ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mhirschcommented, Oct 4, 2022

I’ve been using a patched leaflet with the above one line change for 4 months without problems.

0reactions
raychankscommented, Oct 14, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found