flutter_map icon indicating copy to clipboard operation
flutter_map copied to clipboard

[FEATURE] Improve `Scalebar` at low zoom levels

Open S-Man42 opened this issue 6 months ago • 16 comments

What is the bug?

I really love to see this feature. However, it seems not to be correct.

The scale shows a distance of 1000km in the horizontal distance.

Screenshot_20240819_210047_Brave

In fact, it is not more than 650km.

I guess it results from the problem, that the mercator projection yield different distances throughout the map for same pixel distances depending on latitude.

But in this case it is not quite clear which latitude it shows. Does it measures the rhumb line or geodetic lengths? Currently it may show wring results as you can see.

I guess it could be a good idea to configure the scale this way, that it shows the distance of the start and end points lying exactly under the bar.

Second point would be to decide which length you really display. The shortest length (geodetic) between start and end point of the scale, but in that case it is not a straight line and the half marker would not be at the drawed position. If one would show the length of the straight line as the scale bar shows, you would need the length of the rhumb line. (in mercator projection).

Funny enough: Googles scale is also not that precise, I believe:

Screenshot_20240821_073423_Maps

How can we reproduce it?

Add ScaleBar layer and scroll to any area you know its diameter

Do you have a potential solution?

I would tried following, I don't know if it works

(for left alignment, others are similar)

Take the pixel position of the starting point of the scale. Convert it to the coordinate exactly below it. Calculate the rhumb line length exactly <currently. displayed scale unit/meters, i.e. 200km> east. Convert this back to the current pixel coords as end point, draw line.

In my opinion this should ensure that the scale exactly shows the length of the rhumbline which is exactly below it. So one could do measuring by panning the map right under the scale. If would choose rhumbline over geodetic's length because it shows a straight line on a mercator projection and hence it should not calc a "curved" geodetic's length in my opinion. It's relevant for huge distances. For smaller ones one could think about switching to geodetics since the performance could be probably increased and difference is very small.

Platforms

Tested in web demo

Severity

Minimum: Allows normal functioning

S-Man42 avatar Aug 21 '24 05:08 S-Man42