filterInsideRadius method

  1. @override
List<LatLng> filterInsideRadius(
  1. List<LatLng> locations,
  2. double radius, {
  3. DistanceAlgorithmType algorithm = DistanceAlgorithmType.Haversine,
  4. LengthUnit unit = LengthUnit.M,
})
override

Filter locations to only contains LatLng within a specified radius.

locations list of LatLng locations to be filtered radius radius to be used to filter locations algorithm calculation algorithm to be used. Available values DistanceAlgorithmType.Haversine and DistanceAlgorithmType.Vincenty

        Default [DistanceAlgorithmType.Haversine]

unit unit of radius. Default in meters LengthUnit.M

Implementation

@override
List<LatLng> filterInsideRadius(
  List<LatLng> locations,
  double radius, {
  DistanceAlgorithmType algorithm = DistanceAlgorithmType.Haversine,
  LengthUnit unit = LengthUnit.M,
}) {
  List<LatLng> result = [];

  for (LatLng location in locations) {
    if (isInsideRadius(location, radius, algorithm: algorithm, unit: unit)) {
      result.add(location);
    }
  }

  return result;
}