# Coordinates

General utilities and types that relate to working with and manipulating geographic information or geometries.

## LngLat

A `LngLat`

object represents a given longitude and latitude coordinate, measured in degrees.
These coordinates are based on the WGS84
(EPSG:4326) standard.

SDK JS uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match the GeoJSON specification.

Note that any SDK JS method that accepts a `LngLat`

object as an argument or option
can also accept an `Array`

of two numbers and will perform an implicit conversion.
This flexible type is documented as LngLatLike.

### Example

### Parameters

### Static Members

Converts an array of two numbers or an object with `lng`

and `lat`

or
`lon`

and `lat`

properties
to a `LngLat`

object.

If a `LngLat`

object is passed in, the function returns it unchanged.

##### Parameters

##### Returns

`LngLat`

: A new
`LngLat`

object, if a conversion occurred, or the original
`LngLat`

object.
##### Example

### Methods

Returns the approximate distance between a pair of coordinates in meters Uses the Haversine Formula (from R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159)

##### Parameters

##### Returns

`number`

:
Distance in meters between the two coordinates.
##### Example

Returns a `LngLatBounds`

from the coordinates extended by a given `radius`

. The
returned `LngLatBounds`

completely contains the `radius`

.

##### Parameters

##### Returns

`LngLatBounds`

:
A new
`LngLatBounds`

object representing the coordinates extended by the
`radius`

.
##### Example

### Related examples

## Point

A Point two numbers representing
`x`

and `y`

screen coordinates in pixels.

### Example

### Parameters

### Static Members

Construct a point from an array if necessary, otherwise if the input is already a Point, or an unknown type, return it unchanged.

##### Parameters

##### Returns

`Point`

:
The new constructed point, or passed-through value..
##### Example

### Methods

Add this point's x & y coordinates to another point, yielding a new point.

##### Parameters

##### Returns

`Point`

:
The new point.
##### Example

Get the angle from this point to another point, in radians

##### Parameters

##### Returns

`number`

:
The angle in radians.
##### Example

Get the angle between this point and another point, in radians

##### Parameters

##### Returns

`number`

:
The angle in radians.
##### Example

Calculate the distance from this point to another point.

##### Parameters

##### Returns

`number`

:
The distance.
##### Example

Calculate the distance from this point to another point, without the square root step. Useful if you're comparing relative distances.

##### Parameters

##### Returns

`number`

:
The distance.
##### Example

Divide this point's x & y coordinates by a factor, yielding a new point.

##### Parameters

##### Returns

`Point`

:
The new point.
##### Example

Divide this point's x & y coordinates by point, yielding a new point.

##### Parameters

##### Returns

`Point`

:
The new point.
##### Example

Judge whether this point is equal to another point, returning true or false.

##### Parameters

##### Returns

`boolean`

:
Whether the points are equal.
##### Example

Multiply this point by a 4x1 transformation matrix.

##### Parameters

##### Returns

`Point`

:
The new point.
##### Example

Multiply this point's x & y coordinates by a factor, yielding a new point.

##### Parameters

##### Returns

`Point`

:
The new point.
##### Example

Multiply this point's x & y coordinates by point, yielding a new point.

##### Parameters

##### Returns

`Point`

:
The new point.
##### Example

Rotate this point around the 0, 0 origin by an angle a, given in radians.

##### Parameters

##### Returns

`Point`

:
The new point.
##### Example

Subtract this point's x & y coordinates to from point, yielding a new point.

##### Parameters

##### Returns

`Point`

:
The new point.
##### Example

## LngLatBounds

A `LngLatBounds`

object represents a geographical bounding box,
defined by its southwest and northeast points in longitude and latitude.

If no arguments are provided to the constructor, a `null`

bounding box is created.

Note that any Mapbox GL method that accepts a `LngLatBounds`

object as an argument or option
can also accept an `Array`

of two LngLatLike constructs and will perform an implicit
conversion.
This flexible type is documented as LngLatBoundsLike.

### Example

### Parameters

### Static Members

Converts an array to a `LngLatBounds`

object.

If a `LngLatBounds`

object is passed in, the function returns it unchanged.

Internally, the function calls `LngLat#convert`

to convert arrays to `LngLat`

values.

##### Parameters

##### Returns

`LngLatBounds`

:
A new
`LngLatBounds`

object, if a conversion occurred, or the original
`LngLatBounds`

object.
##### Example

### Methods

Check if the point is within the bounding box.

##### Parameters

##### Returns

`boolean`

:
True if the point is within the bounding box.
##### Example

Extend the bounds to include a given LngLatLike or LngLatBoundsLike.

##### Parameters

##### Returns

`LngLatBounds`

:
`this`

## LngLatLike

A LngLat object, an array of two numbers representing
longitude and latitude,
or an object with `lng`

and `lat`

or `lon`

and `lat`

properties.

### Example

## PointLike

A Point or an array of two numbers representing
`x`

and `y`

screen coordinates in pixels.

### Example

## LngLatBoundsLike

A LngLatBounds object, an array of LngLatLike objects in [sw, ne] order, or an array of numbers in [west, south, east, north] order.

### Example

## MercatorCoordinate

src/geo/mercator_coordinate.ts

A `MercatorCoordinate`

object represents a projected three dimensional position.

`MercatorCoordinate`

uses the web mercator projection (EPSG:3857)
with slightly different units:

- the size of 1 unit is the width of the projected world instead of the "mercator meter"
- the origin of the coordinate space is at the north-west corner instead of the middle

For example, `MercatorCoordinate(0, 0, 0)`

is the north-west corner of the mercator world and
`MercatorCoordinate(1, 1, 0)`

is the south-east corner. If you are familiar with
vector tiles it may be helpful to think
of the coordinate space as the `0/0/0`

tile with an extent of `1`

.

The `z`

dimension of `MercatorCoordinate`

is conformal. A cube in the mercator coordinate
space would be rendered as a cube.

### Example

### Parameters

### Static Members

Project a `LngLat`

to a `MercatorCoordinate`

.

##### Parameters

##### Returns

`MercatorCoordinate`

:
The projected mercator coordinate.
##### Example

### Methods

### Related examples

## EdgeInsets

An `EdgeInset`

object represents screen space padding applied to the edges of the viewport.
This shifts the apprent center or the vanishing point of the map. This is useful for adding floating UI elements
on top of the map and having the vanishing point shift as UI elements resize.

### Parameters

### Static Members

Utility method that computes the new apprent center or vanishing point after applying insets. This is in pixels and with the top left being (0.0) and +y being downwards.

##### Parameters

##### Returns

`Point`

: the point
Interpolates the inset in-place.
This maintains the current inset value for any inset not present in `target`

.

##### Parameters

##### Returns

`EdgeInsets`

:
the insets
Returns the current state as json, useful when you want to have a read-only representation of the inset.

##### Returns

`PaddingOptions`

:
state as json