Distance on Map point point and point to line not equal

Hi at all!
I'm trying to measure distance from one marker and a line but i thing there is one problem in formulas.
I place a second marker at he end of the second line.
I measure distance point to point, point to line and line to line.
Point to line and line to line have same value, but different from point to point. Whi? what's wrong?
thanks paolo
here is screen

and here are bloks

I try to implement the formula in this papaer:
Calculate distance and bearing between two Latitude/Longitude points using haversine formula in JavaScript like suggested in another discussion.
It work fine. i place third point and calculate distance rom line.
In this way i can know the side in respect of the line too.

This shows what happens

LineString.DistanceToPoint centroid should be false as coded. The distance is computed from the closest point on the LineString to the given point. which should be the correct setting.

Marker1 to Marker2 distance is supposedly correct.

If I include the map scale and compare it with the the calculations, the 1113 km indicates the LineString.DistanceToPoint is not calculating correctly and they should be 778. So the Distance to point from the LineString and between the Line strings are in error by a large amount.

So, what are we missing.

It would be reasonable to see small differences but the difference between 778 m and 1113 m is significant.

Perhaps MIT developers can explain this behavior ?