distanceTo

fun distanceTo(other: Coordinate, formula: DistanceFormula = DistanceFormula.HAVERSINE_WITH_LEVELS): Double?

Calculates the distance (measured in meters) from the current object’s coordinate to the specified coordinate. This uses the Haversine formula to account for global curvature.

Here we don't use Android default Location.distanceTo because it gives a bit different results comparing to iOS and Backend

Return

The distance (in meters) between the two coordinates. Null if coordinates are at different levels when used DistanceFormula.HAVERSINE_WITH_LEVELS formula.

Parameters

other

The destination coordinate.

formula

The desired formula to calculate distance. Default is DistanceFormula.HAVERSINE_WITH_LEVELS