distance method
Calculates distance with Haversine algorithm.
Accuracy can be out by 0.3% More on Wikipedia
Implementation
@override
double distance(final LatLng p1, final LatLng p2) {
final sinDLat = math.sin((p2.latitudeInRad - p1.latitudeInRad) / 2);
final sinDLng = math.sin((p2.longitudeInRad - p1.longitudeInRad) / 2);
// Sides
final a = sinDLat * sinDLat +
sinDLng *
sinDLng *
math.cos(p1.latitudeInRad) *
math.cos(p2.latitudeInRad);
final c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a));
return equatorRadius * c;
}