distance method

  1. @override
double distance(
  1. dynamic toDestination, {
  2. DistanceAlgorithmType algorithm = DistanceAlgorithmType.Haversine,
  3. LengthUnit unit = LengthUnit.M,
})
override

Calculate distance between current center of the map with toDestination.

toDestination target location to calculate the distance algorithm calculation algorithm to be used. Available values DistanceAlgorithmType.Haversine and DistanceAlgorithmType.Vincenty

        Default [DistanceAlgorithmType.Haversine]

Implementation

@override
double distance(
  dynamic toDestination, {
  DistanceAlgorithmType algorithm = DistanceAlgorithmType.Haversine,
  LengthUnit unit = LengthUnit.M,
}) {
  bool isVincenty = algorithm == DistanceAlgorithmType.Vincenty;
  Distance d = isVincenty ? DistanceVincenty() : DistanceHaversine();
  return d.distance(map?.center, toDestination, unit: unit);
}