Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] tileSize parameter is broken #1669

Closed
bramp opened this issue Sep 27, 2023 · 6 comments
Closed

[BUG] tileSize parameter is broken #1669

bramp opened this issue Sep 27, 2023 · 6 comments
Assignees
Labels
bug This issue reports broken functionality or another error P: 2 (soon™?) S: docs Scoped to the external documentation
Milestone

Comments

@bramp
Copy link
Contributor

bramp commented Sep 27, 2023

What is the bug?

The TileProvider(tileSize: ) argument does not seem to produce desired maps when set to a value different than 256.

JaffaKetchup did testing in #1668 (comment) here are the appropriate screenshots that show the issues:

0101
0100

These maps are all meant to be centered on England, and you can see that wrapping around the global does not work correctly.

If we also look at MapBox's Static API, a 512 tile, is the same as the 256 tile with the same x, y and z, just at a higher resolution.

How can we reproduce it?

Checkout the example Retina/TileSize page: #1668 or create a map with

TileLayer(
   tileSize: 512
)

Do you have a potential solution?

Sorry no.

Platforms

Chrome

Severity

Erroneous: Prevents normal functioning and causes errors in the console

@bramp bramp added bug This issue reports broken functionality or another error needs triage This new bug report needs reproducing and prioritizing labels Sep 27, 2023
@JaffaKetchup JaffaKetchup added P: 1 (important) and removed needs triage This new bug report needs reproducing and prioritizing labels Sep 28, 2023
@JaffaKetchup
Copy link
Member

Just to note, they are not all necessarily supposed to be centered on England. However, when changing the FM tile size setting, the map does just 'jump' to a different location, which is incorrect.

@V3ntus
Copy link

V3ntus commented Dec 4, 2023

Having this issue as well. Another thing is that this changes where markers or polylines for example are rendered. When using a 512 tile server and setting the tileSize to 512, my polylines are rendered in the middle of a sea:
image

In comparison to their correct location when using 256 (default):
image

@JaffaKetchup JaffaKetchup changed the title [BUG] The tileSize parameter has odd/unexpected behaviour [BUG] tileSize parameter is broken Dec 10, 2023
@JaffaKetchup JaffaKetchup added the S: core Scoped to the core flutter_map functionality label Dec 10, 2023
@JaffaKetchup JaffaKetchup added this to the v7.0 milestone Dec 10, 2023
@josxha josxha moved this to To do in Development Jan 21, 2024
@readyiman
Copy link

I have same issue. Tile request for 256 is 4x of 512 btw, which will affect cost.

@JaffaKetchup JaffaKetchup self-assigned this Jun 6, 2024
@JaffaKetchup
Copy link
Member

The issue occurs because of these lines:

/// Zoom to Scale function.
double scale(double zoom) => 256.0 * math.pow(2, zoom);
/// Scale to Zoom function.
double zoom(double scale) => math.log(scale / 256) / math.ln2;

These assume a tile size of 256. Manually changing these to 512 when using tileSize 512 restores correct functionality.

However, fixing this is likely to be a little difficult, because the Crs is completely seperate to any TileLayer. Although we sometimes have requests to support a different Crs per TileLayer, this comment - #890 (comment) - covers why that's possibly a bad idea.

Therefore, there is an issue here of overall structure - the Crs should not really depend on a value from the TileLayer, but neither should the other layers if we move the multiplication out (or add an argument). I'm really not sure what the best way to solve this is.

@JaffaKetchup
Copy link
Member

JaffaKetchup commented Jun 6, 2024

To fix this issue, use zoomOffset: -1. There's not really much we can do (as described above), and it was also the fix recommended on Leaflet: Leaflet/Leaflet#4391.
I'll add this to the documentation.

@JaffaKetchup JaffaKetchup closed this as not planned Won't fix, can't repro, duplicate, stale Jun 6, 2024
@github-project-automation github-project-automation bot moved this from To do to Done in Development Jun 6, 2024
@JaffaKetchup JaffaKetchup added S: docs Scoped to the external documentation and removed S: core Scoped to the core flutter_map functionality labels Jun 6, 2024
@readyiman
Copy link

To fix this issue, use zoomOffset: -1.

I can confirm this solution does work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue reports broken functionality or another error P: 2 (soon™?) S: docs Scoped to the external documentation
Projects
Archived in project
Development

No branches or pull requests

4 participants