approximateBearingBetween static method

double approximateBearingBetween(
  1. Position startLocation,
  2. Position endLocation
)

Implementation

static double approximateBearingBetween(
    Position startLocation, Position endLocation) {
  double bearing = 0;
  const double latLongFactor = 1.33975031663;

  final Position startCoordinate = startLocation;
  final Position endCoordinate = endLocation;

  final double latitudeDistance =
      startCoordinate.latitude - endCoordinate.latitude;
  final double longitudeDistance =
      startCoordinate.longitude - endCoordinate.longitude;

  bearing =
      (atan2(longitudeDistance, (latitudeDistance * latLongFactor.toDegrees)))
          .toDegrees;
  bearing += 180.0;

  return bearing;
}