calculateDistance static method

double calculateDistance(
  1. dynamic lat1,
  2. dynamic lon1,
  3. dynamic lat2,
  4. dynamic lon2,
)

Implementation

static double calculateDistance(lat1, lon1, lat2, lon2) {
  var p = 0.017453292519943295;
  var c = cos as double Function(num?);
  var a = 0.5 -
      c((lat2 - lat1) * p) / 2 +
      c(lat1 * p) * c(lat2 * p) * (1 - c((lon2 - lon1) * p)) / 2;
  return 12742 * 1000 * asin(sqrt(a));
}