Skip to main content

flywave-mapview.mapview.lookat

Home > @flywave/flywave-mapview > MapView > lookAt

MapView.lookAt() method

Adjusts the camera to look at a given geo coordinate with tilt and heading angles.

Signature:

lookAt(params: Partial<LookAtParams>): void;

Parameters

Parameter

Type

Description

params

Partial<LookAtParams>

LookAtParams

Returns:



void

## Remarks

\#\#\#\# Note on `target` and `bounds`

If `bounds` are specified, `zoomLevel` and `distance` parameters are ignored and `lookAt` calculates best zoomLevel (and possibly target) to fit given bounds.

Following table shows how relation between `bounds` and target.

\| `bounds` \| `target` \| actual `target` \| \-\-\-\-\-\- \| \-\-\-\-\-\- \| \-\-\-\-\-\--- \| \| \_defined\_ \| `params.target` is used \| \| `undefined` \| `bounds.center` is used as new `target` \| \| `undefined` \| current `MapView.target` is used \| \| \_defined\_ \| `params.target` is used \| \[\[GeoCoordLike\]\]\[\] \| `undefined` \| new `target` is calculated as center of world box covering given points \| \[\[GeoCoordLike\]\]\[\] \| \_defined\_ \| `params.target` is used and zoomLevel is adjusted to view all given geo points

In each case, `lookAt` finds minimum `zoomLevel` that covers given extents or geo points.

With flat projection, if `bounds` represents points on both sides of anti-meridian, and [MapViewOptions.tileWrappingEnabled](./flywave-mapview.mapviewoptions.tilewrappingenabled.md) is used, `lookAt` will use this knowledge and find minimal view that may cover "next" or "previous" world.

With sphere projection if `bounds` represents points on both sides of globe, best effort method is used to find best `target`<!-- -->\`<!-- -->.

\#\#\#\# Examples

```typescript
mapView.lookAt(&#123;heading: 90&#125;)
// look east retaining current `target`, `zoomLevel` and `tilt`

mapView.lookAt(&#123;lat: 40.707, lng: -74.01&#125;)
// look at Manhattan, New York retaining other view params

mapView.lookAt(bounds: &#123; latitudeSpan: 10, longitudeSpan: 10&#125;)
// look at current `target`, but extending zoomLevel so we see 10 degrees of lat/long span