fleaflet / flutter_map

A versatile mapping package for Flutter. Simple and easy to learn, yet completely customizable and configurable, it's the best choice for mapping in your Flutter app.
https://pub.dev/packages/flutter_map
BSD 3-Clause "New" or "Revised" License
2.76k stars 860 forks source link

[BUG] `{d}` `urlTemplate` placeholder improperly converted to string on non-web platforms #1936

Open geoextra opened 3 months ago

geoextra commented 3 months ago

What is the bug?

When using the {d} in the urlTemplate (introduced in #1665) it defaults to a float value which gets converted to string (e.g. 256.0). This is obviously not supported by many tile providers.

How can we reproduce it?

Use the following option: urlTemplate: 'https://api.mapbox.com/styles/v1/mapbox/streets-v12/tiles/{d}/{z}/{x}/{y}{r}?access_token=$mapboxPublicToken'. The tile server will respond with 422 status codes. Problem doesn't occur on web due to differences in types and therefore toString().

Do you have a potential solution?

I don't see why the resolution needs to be a double, maybe it can be changed to an integer type.

Platforms

Android 14

Severity

Erroneous: Prevents normal functioning and causes errors in the console

JaffaKetchup commented 3 months ago

Hey @geoextra, can you confirm if you mean the {d} placeholder instead? {r} is for retina mode.

(If you want to use x512 tiles, you can set tileSize: 512, use 512 or {d} (when fixed) in the URL, and set zoomOffset: -1.)

geoextra commented 3 months ago

Yes, of course, I edited the title, thanks.

JaffaKetchup commented 3 months ago

I'm not sure why we accept decimals for the tile size, that really doesn't make sense.

A less intrusive short term fix is to just assume the number is an integer before converting it (which it should be), otherwise fall back to this behaviour.

We'll discuss internally which is best. Thanks for the report!