bryceco / GoMap

OpenStreetMap editor for iPhone/iPad
ISC License
301 stars 40 forks source link

Show only one distance unit in ruler #737

Closed verhovsky closed 2 months ago

verhovsky commented 3 months ago

Closes #726

The initial unit system is set from the user's system locale. pressing on the bar changes the unit (which in my opinion is a bad idea, it should be a setting because users are going to press it accidentally and then have no idea why it changed or how to change it back, just as you didn't know that clicking the scale bar on iD changes the units). changing your locale in system settings also changes the unit, regardless of what it was set to before.

I also changed it to use monospace numbers so that the "m" doesn't jitter around as much as you zoom. it still jitters when you go between adding/removing the decimal point and more or less numbers. and made it always use at least 3 digits.

I also removed the black line and left-aligned the text

minimal
verhovsky commented 3 months ago

I tried setting the ruler's length from the ruler's position, not the center of the screen, because the US is about 4500 km across, not 597 km

shortus

but it still doesn't work right when you're really zoomed out, it measures the US to be like 1300 km now

bryceco commented 3 months ago

The distances are wrong because the coordinate system for mapView is not what you expect: The center of the view is (0,0).

If you use: let left = convert(CGPoint(x: bounds.minX, y: bounds.midY), to: mapView) let right = convert(CGPoint(x: bounds.maxX, y: bounds.midY), to: mapView) then the distances work correctly.

bryceco commented 3 months ago

While the ruler without the black line looks pretty nice, there are times when there isn't enough contrast to tell where the edges are. Try measuring the US with the mapnik background and you'll see what I mean.