# boundsOfPoints

The smallest latitude and longitude box holding every point, with its
latitudes clamped to valid coordinates. Used to fit the map to a feature.

This is a function exported by `@mapcairn/core`, checked against version 0.2.0.

## Signature

```ts
import { boundsOfPoints } from "@mapcairn/core";
 
function boundsOfPoints(points: readonly LatLng[]): Bounds | undefined;
```

## Parameters

- `points` (`readonly LatLng[]`)

## Returns

`Bounds | undefined`: `undefined` when no point has finite coordinates.

## Remarks

The box takes the short way round the globe. Points on both sides
 of the antimeridian give a `west` inside [-180, 180) and an `east` past
 180 (179 and -179 give 179 to 181), the form `shapeInputBounds` and
 [`shortestLongitudeSpan`](https://docs.mapcairn.com/api/core/shortestLongitudeSpan.md) already use, so `west` is never greater than
 `east` and a caller that reads width as `east - west` stays correct. A box
 that does not cross the line keeps both edges inside [-180, 180]. Take the
 middle with `wrapLongitude((west + east) / 2)`. The engine's `fitBounds`
 accepts the unwrapped `east`. A set of points wider than half the globe
 with a wide gap in it may be boxed on the other side of the gap, because
 points say nothing about what lies between them. For a polygon or a line,
 use [`boundsOfPaths`](https://docs.mapcairn.com/api/core/boundsOfPaths.md), which also holds every edge.

## See also

- [`LatLng`](https://docs.mapcairn.com/api/core/LatLng.md)
- [`Bounds`](https://docs.mapcairn.com/api/core/Bounds.md)

Source: [packages/core/src/spatial/boundsOfPoints.ts:23](https://github.com/MapCairn/mapcairn/blob/main/packages/core/src/spatial/boundsOfPoints.ts#L23)
