computeBounds static method

LatLngBounds computeBounds(
  1. List<RoutePoint> points, {
  2. LatLng? startPoint,
})

Returns a LatLngBounds that covers all points.

If startPoint is provided it is also included in the bounds.

Implementation

static LatLngBounds computeBounds(List<RoutePoint> points,
    {LatLng? startPoint}) {
  final latitudes = [
    ...points.map((p) => p.location.latitude),
    if (startPoint != null) startPoint.latitude,
  ];
  final longitudes = [
    ...points.map((p) => p.location.longitude),
    if (startPoint != null) startPoint.longitude,
  ];

  return LatLngBounds(
    southwest: LatLng(latitudes.reduce(min), longitudes.reduce(min)),
    northeast: LatLng(latitudes.reduce(max), longitudes.reduce(max)),
  );
}