calculateBearing method
Implementation
double calculateBearing(LatLng start, LatLng end) {
double startLat = start.latitude * (pi / 180.0);
double startLng = start.longitude * (pi / 180.0);
double endLat = end.latitude * (pi / 180.0);
double endLng = end.longitude * (pi / 180.0);
double dLng = endLng - startLng;
double y = sin(dLng) * cos(endLat);
double x = cos(startLat) * sin(endLat) - sin(startLat) * cos(endLat) * cos(dLng);
double bearing = atan2(y, x) * (180.0 / pi);
return (bearing + 360.0) % 360.0;
}