distance method
double
distance(
- dynamic toDestination, {
- DistanceAlgorithmType algorithm = DistanceAlgorithmType.Haversine,
- 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);
}