metersTo method
Measures the distance between this
instance and the provided location
Returns: The distance between the two coordinates in meters as a double
Note: This is a primitive Haversine implementation. For more accuracy or advanced options, consider using latlong2 or adopting the code from it's GitHub source dart-latlong
Implementation
double metersTo(T location) {
var l1LatRad = _deg2rad(latitude);
var l1LonRad = _deg2rad(longitude);
var l2LatRad = _deg2rad(location.latitude);
var l2LonRad = _deg2rad(location.longitude);
final sinDLat = math.sin((l2LatRad - l1LatRad) / 2);
final sinDLng = math.sin((l2LonRad - l1LonRad) / 2);
final a = sinDLat * sinDLat +
sinDLng * sinDLng * math.cos(l1LatRad) * math.cos(l2LatRad);
final c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a));
return _kEquatorRadius * c;
}