In the sheet, how to calculate the distance between two LatLng objects?

There is a latlng distanceTo method: http://leafletjs.com/reference.html#latlng

distanceTo( <LatLng> otherLatlng ) Number Returns the distance (in meters) to the given LatLng calculated using the Haversine formula. See description on wikipedia 

It calculates the distance (in meters) between two LatLng. However, sometimes I need to know how many pixels are between two points. Anyone have any ideas on this?

+6
source share
1 answer

You can convert your coordinates to screen points using:

http://leafletjs.com/reference.html#map-latlngtolayerpoint

Then measure the distance between the two points:

http://leafletjs.com/reference.html#point-distanceto

+5
source

Source: https://habr.com/ru/post/987923/


All Articles