Skip to content

Conversation

@monsieurtanuki
Copy link
Contributor

@monsieurtanuki monsieurtanuki commented Jul 22, 2025

Fixed the case where zoomOffset is negative.
Couldn't test it properly, e.g. with Retina Tile Layer example.

{Edit] I did manage to reproduce the bug though, by forcing zoomOffset to -1.

@JaffaKetchup JaffaKetchup linked an issue Jul 22, 2025 that may be closed by this pull request
@JaffaKetchup JaffaKetchup requested a review from a team July 22, 2025 20:11
Copy link
Member

@JaffaKetchup JaffaKetchup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look like it works quite right :(

image

@monsieurtanuki
Copy link
Contributor Author

This doesn't look like it works quite right :(

Ah, everything's got to be perfect with you! 😉

That said, as explained I couldn't see how to test the code, more specifically cases with a zoomOffset different from 0. Any suggestion?

@JaffaKetchup
Copy link
Member

To be fair, I don't know necessarily what I would expect to see with a negative zoom offset - maybe that screenshot is what it's supposed to be? I'll have a look at what it looked like on an older version.

@JaffaKetchup
Copy link
Member

Maybe this is working correctly. Using this code to test:

TileLayer(
      zoomOffset: -1,
      minNativeZoom: 1,
      maxNativeZoom: 18,
      urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
      userAgentPackageName: 'dev.fleaflet.flutter_map.example',
      tileProvider: NetworkTileProvider(httpClient: httpClient),
    );

I think yesterday I tested without a minNativeZoom, which would obviously cause problems. Nevermind!

Ah, everything's got to be perfect with you! 😉

Sorry, you're right 😅

Copy link
Member

@JaffaKetchup JaffaKetchup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this works correctly. Will try to ask original reporter to test, but seems to be OK. Thanks and apologies :)

@JaffaKetchup JaffaKetchup changed the title fix: 2127 - tile coordinate simplification with negative zoomOffset fix: prevent negative left-shift when using negative zoomOffset Jul 23, 2025
@JaffaKetchup JaffaKetchup enabled auto-merge (squash) July 23, 2025 09:57
@JaffaKetchup JaffaKetchup merged commit ebc5622 into fleaflet:master Jul 23, 2025
7 checks passed
@mash-g
Copy link

mash-g commented Jul 28, 2025

Hi, thanks for the fix. When do changes reach pub.dev?

@JaffaKetchup
Copy link
Member

Hey @mash-g, I'd be interested to know if this actually fixes an issue you have - I guess a negative offset is more common than I expected 😂

But in answer, we have no fixed release schedule. Likely this one will be waiting for a little bit unless there's another more critical fix soon - I would like to release them faster, but it requires coordination from the rest of the maintainer team, so it's usually not too quick.

I'll open a PR for the release, but have to wait for a review before it can be merged and released.

@mash-g
Copy link

mash-g commented Aug 8, 2025

Hey @JaffaKetchup,

I re-confirmed that with flutter_map v8.2.1, the app generates a "Invalid argument(s): -1" exception which is resolved when the app is linked with the latest version from the main branch. Interestingly, the exception doesn't seem to occur while the map is zoomed in to street level, but becomes guaranteed as the map is zoomed out to country level.

Stack for above exception:

#0      int._shlFromInteger (dart:core-patch/integers.dart:86:42)
integers.dart:86
#1      int.<< (dart:core-patch/integers.dart:117:49)
integers.dart:117
#2      TileCoordinatesResolver.get (package:flutter_map/src/layer/tile_layer/tile_coordinates.dart:83:22)
tile_coordinates.dart:8

In this case, the tile provider API that the app is using sends 512x512 px tiles. As per docs, the app is setting zoomOffset=-((512/256) - 1) in the TileLayer which may have been contributing to this error.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Negative zoomOffset in TileLayer causes crash

3 participants