# Convert between distance values returned by distanceTo() of Point object method and distance() of map Object in Leaflet

I had tried the code pasted below using leaflet.js (latest version):

``````const mapObj = L.map("map", {
center: [51.505, -0.09],
zoom: 9
});

let point1 = L.point([51.505, -0.09]);
let point2 = L.point([51.505, 0.49]);

let pt1LatLng = L.latLng([51.505, -0.09]);
let pt2LatLng = L.latLng([51.505, 0.49]);

console.log("using L.point().distance: ",
point1.distanceTo(point2));

console.log("using mapObj.distance(): ",
mapObj.distance(pt1LatLng, pt2LatLng));
``````

The value returned by L.point().distanceTo() is "0.58" where as the value returned by mapObj.distance() is "40143.36249750451".

How to convert between these two values?

`L.Point`s imply a cartesian coordinate system, and euclidean distances.
`L.LatLng`s imply a spherical coordinate system (with a constant radius of 6371000 meters), and haversine distances.
If you just need to understand the impossibility of converting between the two distances (without knowing the original points), think about the edge case of the distance between two representations of the north pole. The distance between `[90,0]` and `[90,180]` will be 180 on a cartesian plane, but will be zero on a sphere. Compare with the case of two points along the equator: `[0,0]` and `[0,180]`: the euclidean distance between the two is 180, but the haversine distance will be around 20000km.
• You should probably also point out that `L.point([51.505, -0.09])` makes no sense, since `[51.505, -0.09]` are spherical coordinates, but `L.point` expects pixel coordinates. Conversion from spherical to pixel coordinates is possible with the map `latLngToLayerPoint` method. Commented Jul 27 at 14:40
• Worth mentioning maybe is also that Leaflet docs state that map `distance` method "Returns the distance between two geographical coordinates according to the map's CRS." This could be misleading that distance is returned in projected meters, but that's not the case, it returns haversine distance. Commented Jul 27 at 14:45