Reputation: 47051
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 needs to know how many pixels are there between two points. Does anyone have ideas about this?
Upvotes: 7
Views: 8705
Reputation: 14150
You can convert your coordinates to screen points using:
http://leafletjs.com/reference.html#map-latlngtolayerpoint
And then measure the distance between the two points with:
http://leafletjs.com/reference.html#point-distanceto
Upvotes: 8