> For the complete documentation index, see [llms.txt](https://docs.mapbox.com/mapbox-gl-js/ja/llms.txt)

# Geography and geometry

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

## LngLat

[Source Code](https://github.com/mapbox/mapbox-gl-js/blob/29a082c40985763b038163d555f9305cb39233ad/src/geo/lng_lat.ts#L70-L195)

A `LngLat` object represents a given longitude and latitude coordinate, measured in degrees. These coordinates use longitude, latitude coordinate order (as opposed to latitude, longitude) to match the [GeoJSON specification](https://datatracker.ietf.org/doc/html/rfc7946#section-4), which is equivalent to the OGC:CRS84 coordinate reference system.

Note that any Mapbox GL 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](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatlike).

> new LngLat(lng: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, lat: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)

### Parameters

| Name | Description |
| --- | --- |
| **lng** [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)  | Longitude, measured in degrees. |
| **lat** [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)  | Latitude, measured in degrees. |

### Example

```js
const ll = new mapboxgl.LngLat(-123.9749, 40.7736);
console.log(ll.lng); // = -123.9749
```

### Static Members

#### convert()

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

| Name | Description |
| --- | --- |
| **input** [LngLatLike](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatlike)  | An array of two numbers or object to convert, or a `LngLat` object to return. |

##### Returns

[LngLat](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglat): A new `LngLat` object, if a conversion occurred, or the original `LngLat` object.

##### Example

```js
const arr = [-73.9749, 40.7736];
const ll = mapboxgl.LngLat.convert(arr);
console.log(ll);   // = LngLat {lng: -73.9749, lat: 40.7736}
```

### Instance Members

#### wrap()

Returns a new `LngLat` object whose longitude is wrapped to the range (-180, 180).

##### Returns

[LngLat](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglat): The wrapped `LngLat` object.

##### Example

```js
const ll = new mapboxgl.LngLat(286.0251, 40.7736);
const wrapped = ll.wrap();
console.log(wrapped.lng); // = -73.9749
```

#### toArray()

Returns the coordinates represented as an array of two numbers.

##### Returns

[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>: The coordinates represeted as an array of longitude and latitude.

##### Example

```js
const ll = new mapboxgl.LngLat(-73.9749, 40.7736);
ll.toArray(); // = [-73.9749, 40.7736]
```

#### toString()

Returns the coordinates represent as a string.

##### Returns

[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String): The coordinates represented as a string of the format `'LngLat(lng, lat)'` .

##### Example

```js
const ll = new mapboxgl.LngLat(-73.9749, 40.7736);
ll.toString(); // = "LngLat(-73.9749, 40.7736)"
```

#### distanceTo()

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

| Name | Description |
| --- | --- |
| **lngLat** [LngLat](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglat)  | Coordinates to compute the distance to. |

##### Returns

[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number): Distance in meters between the two coordinates.

##### Example

```js
const newYork = new mapboxgl.LngLat(-74.0060, 40.7128);
const losAngeles = new mapboxgl.LngLat(-118.2437, 34.0522);
newYork.distanceTo(losAngeles); // = 3935751.690893987, "true distance" using a non-spherical approximation is ~3966km
```

#### toBounds()

Returns a `LngLatBounds` from the coordinates extended by a given `radius`. The returned `LngLatBounds` completely contains the `radius`.

##### Parameters

| Name | Description |
| --- | --- |
| **radius** [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) (default `0`) | Distance in meters from the coordinates to extend the bounds. |

##### Returns

[LngLatBounds](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatbounds): A new `LngLatBounds` object representing the coordinates extended by the `radius` .

##### Example

```js
const ll = new mapboxgl.LngLat(-73.9749, 40.7736);
ll.toBounds(100).toArray(); // = [[-73.97501862141328, 40.77351016847229], [-73.97478137858673, 40.77368983152771]]
```

### Related

-   [Example: Get coordinates of the mouse pointer](https://www.mapbox.com/mapbox-gl-js/example/mouse-position/)
-   [Example: Display a popup](https://www.mapbox.com/mapbox-gl-js/example/popup/)
-   [Example: Highlight features within a bounding box](https://www.mapbox.com/mapbox-gl-js/example/using-box-queryrenderedfeatures/)
-   [Example: Create a timeline animation](https://www.mapbox.com/mapbox-gl-js/example/timeline-animation/)

## LngLatBounds

[Source Code](https://github.com/mapbox/mapbox-gl-js/blob/29a082c40985763b038163d555f9305cb39233ad/src/geo/lng_lat.ts#L235-L517)

A `LngLatBounds` object represents a geographical bounding box, defined by its southwest and northeast points in [`longitude`](https://docs.mapbox.com/help/glossary/lat-lon/) and [`latitude`](https://docs.mapbox.com/help/glossary/lat-lon/). `Longitude` values are typically set between `-180` to `180`, but can exceed this range if `renderWorldCopies` is set to `true`. `Latitude` values must be within `-85.051129` to `85.051129`.

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](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatlike) constructs and will perform an implicit conversion. This flexible type is documented as [LngLatBoundsLike](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatboundslike).

> new LngLatBounds(sw: <a href="/mapbox-gl-js/api/geography/#lnglatlike">LngLatLike</a>?, ne: <a href="/mapbox-gl-js/api/geography/#lnglatlike">LngLatLike</a>?)

### Parameters

| Name | Description |
| --- | --- |
| **sw** [LngLatLike](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatlike)?  | The southwest corner of the bounding box. |
| **ne** [LngLatLike](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatlike)?  | The northeast corner of the bounding box. |

### Example

```js
const sw = new mapboxgl.LngLat(-73.9876, 40.7661);
const ne = new mapboxgl.LngLat(-73.9397, 40.8002);
const llb = new mapboxgl.LngLatBounds(sw, ne);
```

### Static Members

#### convert()

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

| Name | Description |
| --- | --- |
| **input** [LngLatBoundsLike](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatboundslike)  | An array of two coordinates to convert, or a `LngLatBounds` object to return. |

##### Returns

([LngLatBounds](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatbounds) \| void): A new `LngLatBounds` object, if a conversion occurred, or the original `LngLatBounds` object.

##### Example

```js
const arr = [[-73.9876, 40.7661], [-73.9397, 40.8002]];
const llb = mapboxgl.LngLatBounds.convert(arr);
console.log(llb);   // = LngLatBounds {_sw: LngLat {lng: -73.9876, lat: 40.7661}, _ne: LngLat {lng: -73.9397, lat: 40.8002}}
```

### Instance Members

#### setNorthEast()

Set the northeast corner of the bounding box.

##### Parameters

| Name | Description |
| --- | --- |
| **ne** [LngLatLike](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatlike)  | A [LngLatLike](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatlike) object describing the northeast corner of the bounding box. |

##### Returns

[LngLatBounds](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatbounds): Returns itself to allow for method chaining.

##### Example

```js
const sw = new mapboxgl.LngLat(-73.9876, 40.7661);
const ne = new mapboxgl.LngLat(-73.9397, 40.8002);
const llb = new mapboxgl.LngLatBounds(sw, ne);
llb.setNorthEast([-73.9397, 42.8002]);
```

#### setSouthWest()

Set the southwest corner of the bounding box.

##### Parameters

| Name | Description |
| --- | --- |
| **sw** [LngLatLike](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatlike)  | A [LngLatLike](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatlike) object describing the southwest corner of the bounding box. |

##### Returns

[LngLatBounds](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatbounds): Returns itself to allow for method chaining.

##### Example

```js
const sw = new mapboxgl.LngLat(-73.9876, 40.7661);
const ne = new mapboxgl.LngLat(-73.9397, 40.8002);
const llb = new mapboxgl.LngLatBounds(sw, ne);
llb.setSouthWest([-73.9876, 40.2661]);
```

#### extend()

Extend the bounds to include a given LngLatLike or LngLatBoundsLike.

##### Parameters

| Name | Description |
| --- | --- |
| **obj** ([LngLatLike](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatlike) \| [LngLatBoundsLike](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatboundslike))  | Object to extend to. |

##### Returns

[LngLatBounds](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatbounds): Returns itself to allow for method chaining.

##### Example

```js
const sw = new mapboxgl.LngLat(-73.9876, 40.7661);
const ne = new mapboxgl.LngLat(-73.9397, 40.8002);
const llb = new mapboxgl.LngLatBounds(sw, ne);
llb.extend([-72.9876, 42.2661]);
```

#### getCenter()

Returns the geographical coordinate equidistant from the bounding box's corners.

##### Returns

[LngLat](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglat): The bounding box's center.

##### Example

```js
const llb = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.getCenter(); // = LngLat {lng: -73.96365, lat: 40.78315}
```

#### getSouthWest()

Returns the southwest corner of the bounding box.

##### Returns

[LngLat](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglat): The southwest corner of the bounding box.

##### Example

```js
const llb = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.getSouthWest(); // LngLat {lng: -73.9876, lat: 40.7661}
```

#### getNorthEast()

Returns the northeast corner of the bounding box.

##### Returns

[LngLat](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglat): The northeast corner of the bounding box.

##### Example

```js
const llb = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.getNorthEast(); // LngLat {lng: -73.9397, lat: 40.8002}
```

#### getNorthWest()

Returns the northwest corner of the bounding box.

##### Returns

[LngLat](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglat): The northwest corner of the bounding box.

##### Example

```js
const llb = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.getNorthWest(); // LngLat {lng: -73.9876, lat: 40.8002}
```

#### getSouthEast()

Returns the southeast corner of the bounding box.

##### Returns

[LngLat](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglat): The southeast corner of the bounding box.

##### Example

```js
const llb = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.getSouthEast(); // LngLat {lng: -73.9397, lat: 40.7661}
```

#### getWest()

Returns the west edge of the bounding box.

##### Returns

[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number): The west edge of the bounding box.

##### Example

```js
const llb = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.getWest(); // -73.9876
```

#### getSouth()

Returns the south edge of the bounding box.

##### Returns

[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number): The south edge of the bounding box.

##### Example

```js
const llb = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.getSouth(); // 40.7661
```

#### getEast()

Returns the east edge of the bounding box.

##### Returns

[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number): The east edge of the bounding box.

##### Example

```js
const llb = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.getEast(); // -73.9397
```

#### getNorth()

Returns the north edge of the bounding box.

##### Returns

[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number): The north edge of the bounding box.

##### Example

```js
const llb = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.getNorth(); // 40.8002
```

#### toArray()

Returns the bounding box represented as an array.

##### Returns

[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>>: The bounding box represented as an array, consisting of the southwest and northeast coordinates of the bounding represented as arrays of numbers.

##### Example

```js
const llb = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.toArray(); // = [[-73.9876, 40.7661], [-73.9397, 40.8002]]
```

#### toString()

Return the bounding box represented as a string.

##### Returns

[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String): The bounding box represents as a string of the format `'LngLatBounds(LngLat(lng, lat), LngLat(lng, lat))'` .

##### Example

```js
const llb = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.toString(); // = "LngLatBounds(LngLat(-73.9876, 40.7661), LngLat(-73.9397, 40.8002))"
```

#### isEmpty()

Check if the bounding box is an empty/`null`-type box.

##### Returns

[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean): True if bounds have been defined, otherwise false.

##### Example

```js
const llb = new mapboxgl.LngLatBounds();
llb.isEmpty(); // true
llb.setNorthEast([-73.9876, 40.7661]);
llb.setSouthWest([-73.9397, 40.8002]);
llb.isEmpty(); // false
```

#### contains()

Check if the point is within the bounding box.

##### Parameters

| Name | Description |
| --- | --- |
| **lnglat** [LngLatLike](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatlike)  | Geographic point to check against. |

##### Returns

[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean): True if the point is within the bounding box.

##### Example

```js
const llb = new mapboxgl.LngLatBounds(
  new mapboxgl.LngLat(-73.9876, 40.7661),
  new mapboxgl.LngLat(-73.9397, 40.8002)
);

const ll = new mapboxgl.LngLat(-73.9567, 40.7789);

console.log(llb.contains(ll)); // = true
```

## LngLatBoundsLike

[Source Code](https://github.com/mapbox/mapbox-gl-js/blob/29a082c40985763b038163d555f9305cb39233ad/src/geo/lng_lat.ts#L519-L531)

A [LngLatBounds](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatbounds) object, an array of [LngLatLike](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatlike) objects in [sw, ne] order, or an array of numbers in [west, south, east, north] order.

### Type

([LngLatBounds](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatbounds) \| [[LngLatLike](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatlike), [LngLatLike](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatlike)] \| [[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)])

### Example

```js
const v1 = new mapboxgl.LngLatBounds(
  new mapboxgl.LngLat(-73.9876, 40.7661),
  new mapboxgl.LngLat(-73.9397, 40.8002)
);
const v2 = new mapboxgl.LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
const v3 = [[-73.9876, 40.7661], [-73.9397, 40.8002]];
```

## LngLatLike

[Source Code](https://github.com/mapbox/mapbox-gl-js/blob/29a082c40985763b038163d555f9305cb39233ad/src/geo/lng_lat.ts#L197-L206)

A [LngLat](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglat) object, an array of two numbers representing longitude and latitude, or an object with `lng` and `lat` or `lon` and `lat` properties.

### Type

([LngLat](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglat) \| {lng: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), lat: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)} \| {lon: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), lat: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)} \| [[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)])

### Example

```js
const v1 = new mapboxgl.LngLat(-122.420679, 37.772537);
const v2 = [-122.420679, 37.772537];
const v3 = {lon: -122.420679, lat: 37.772537};
```

## MercatorCoordinate

[Source Code](https://github.com/mapbox/mapbox-gl-js/blob/29a082c40985763b038163d555f9305cb39233ad/src/geo/mercator_coordinate.ts#L105-L180)

A `MercatorCoordinate` object represents a projected three dimensional position.

`MercatorCoordinate` uses the web mercator projection ([EPSG:3857](https://epsg.io/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](https://github.com/mapbox/vector-tile-spec) 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.

> new MercatorCoordinate(x: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, y: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, z: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)

### Parameters

| Name | Description |
| --- | --- |
| **x** [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)  | The x component of the position. |
| **y** [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)  | The y component of the position. |
| **z** [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) (default `0`) | The z component of the position. |

### Example

```js
const nullIsland = new mapboxgl.MercatorCoordinate(0.5, 0.5, 0);
```

### Static Members

#### fromLngLat()

Project a `LngLat` to a `MercatorCoordinate`.

##### Parameters

| Name | Description |
| --- | --- |
| **lngLatLike** [LngLatLike](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglatlike)  | The location to project. |
| **altitude** [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) (default `0`) | The altitude in meters of the position. |

##### Returns

[MercatorCoordinate](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#mercatorcoordinate): The projected mercator coordinate.

##### Example

```js
const coord = mapboxgl.MercatorCoordinate.fromLngLat({lng: 0, lat: 0}, 0);
console.log(coord); // MercatorCoordinate(0.5, 0.5, 0)
```

### Instance Members

#### toLngLat()

Returns the `LngLat` for the coordinate.

##### Returns

[LngLat](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#lnglat): The `LngLat` object.

##### Example

```js
const coord = new mapboxgl.MercatorCoordinate(0.5, 0.5, 0);
const lngLat = coord.toLngLat(); // LngLat(0, 0)
```

#### toAltitude()

Returns the altitude in meters of the coordinate.

##### Returns

[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number): The altitude in meters.

##### Example

```js
const coord = new mapboxgl.MercatorCoordinate(0, 0, 0.02);
coord.toAltitude(); // 6914.281956295339
```

#### meterInMercatorCoordinateUnits()

Returns the distance of 1 meter in `MercatorCoordinate` units at this latitude.

For coordinates in real world units using meters, this naturally provides the scale to transform into `MercatorCoordinate`s.

##### Returns

[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number): Distance of 1 meter in `MercatorCoordinate` units.

##### Example

```js
// Calculate a new MercatorCoordinate that is 150 meters west of the other coord.
const coord = new mapboxgl.MercatorCoordinate(0.5, 0.25, 0);
const offsetInMeters = 150;
const offsetInMercatorCoordinateUnits = offsetInMeters * coord.meterInMercatorCoordinateUnits();
const westCoord = new mapboxgl.MercatorCoordinate(coord.x - offsetInMercatorCoordinateUnits, coord.y, coord.z);
```

### Related

-   [Example: Add a custom style layer](https://www.mapbox.com/mapbox-gl-js/example/custom-style-layer/)

## Point

[Source Code](https://github.com/mapbox/mapbox-gl-js/blob/29a082c40985763b038163d555f9305cb39233ad/src/ui/map.ts#L5444-L5451)

A [`Point` geometry](https://github.com/mapbox/point-geometry) object, which has `x` and `y` screen coordinates in pixels, or other units.

### Type

[Point](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#point)

### Example

```js
const point = new mapboxgl.Point(400, 525);
```

## PointLike

[Source Code](https://github.com/mapbox/mapbox-gl-js/blob/29a082c40985763b038163d555f9305cb39233ad/src/ui/map.ts#L5453-L5460)

A [Point](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#point) or an array of two numbers representing `x` and `y` screen coordinates in pixels, or other units.

### Type

([Point](https://docs.mapbox.com/mapbox-gl-js/ja/mapbox-gl-js/api/geography/#point) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>)

### Example

```js
const p1 = new mapboxgl.Point(400, 525); // a PointLike which is a Point
const p2 = [400, 525]; // a PointLike which is an array of two numbers
```