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

# Geography and geometry

This page includes reference documentation for geography and geometry utilities in the **Mapbox Search JS Core** framework.

### LngLat

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 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](#lnglatlike).

> new LngLat(lng: any, lat: any)

#### Import[​](#import)

```javascript
import { LngLat } from '@mapbox/search-js-core'
```

#### Parameters

| Name | Description |
| --- | --- |
| **lng** any  | Longitude, measured in degrees. |
| **lat** any  | Latitude, measured in degrees. |

#### Example

```js
const ll = new 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 a copy.

###### Parameters

| Name | Description |
| --- | --- |
| **input** ([LngLat](#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)])  | An array of two numbers or object to convert, or a `LngLat` object to return. |

###### Returns

[LngLat](#lnglat): A new `LngLat` object, if a conversion occurred, or the original `LngLat` object.

#### Import[​](#import)

```javascript
import { convert } from '@mapbox/search-js-core'
```

###### Example

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

#### Instance Members

##### lng

##### lat

##### toArray()

Returns the coordinates represented as an array of two numbers.

###### Returns

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

#### Import[​](#import)

```javascript
import { toArray } from '@mapbox/search-js-core'
```

###### Example

```js
const ll = new 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)'` .

#### Import[​](#import)

```javascript
import { toString } from '@mapbox/search-js-core'
```

###### Example

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

このsection on LngLatは役に立ちましたか？[Yes](null)[No](null)

### LngLatLike

A [LngLat](#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](#lnglat) \| [[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)] \| {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)})

#### Example

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

このsection on LngLatLikeは役に立ちましたか？[Yes](null)[No](null)

### LngLatBounds

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

Note that any method that accepts a `LngLatBounds` object as an argument or option can also accept an `Array` of two [LngLatLike](#lnglatlike) constructs and will perform an implicit conversion. This flexible type is documented as [LngLatBoundsLike](#lnglatboundslike).

> new LngLatBounds()

#### Import[​](#import)

```javascript
import { LngLatBounds } from '@mapbox/search-js-core'
```

#### Static Members

##### convert()

Converts an array to a `LngLatBounds` object.

If a `LngLatBounds` object is passed in, the function returns a copy.

Internally, the function calls `LngLat#convert` to convert arrays to `LngLat` values.

###### Parameters

| Name | Description |
| --- | --- |
| **input** ([LngLatBounds](#lnglatbounds) \| [[LngLatLike](#lnglatlike), [LngLatLike](#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)])  | An array of two coordinates to convert, or a `LngLatBounds` object to return. |

###### Returns

[LngLatBounds](#lnglatbounds): A new `LngLatBounds` object, if a conversion occurred, or the original `LngLatBounds` object.

#### Import[​](#import)

```javascript
import { convert } from '@mapbox/search-js-core'
```

###### Example

```js
const arr = [[-73.9876, 40.7661], [-73.9397, 40.8002]];
const llb = 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

##### getSouthWest()

Returns the southwest corner of the bounding box.

###### Returns

[LngLat](#lnglat): The southwest corner of the bounding box.

#### Import[​](#import)

```javascript
import { getSouthWest } from '@mapbox/search-js-core'
```

###### Example

```js
const llb = new 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](#lnglat): The northeast corner of the bounding box.

#### Import[​](#import)

```javascript
import { getNorthEast } from '@mapbox/search-js-core'
```

###### Example

```js
const llb = new 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. This is commonly used as the 'min' point in the bounding box.

###### Returns

[LngLat](#lnglat): The northwest corner of the bounding box.

#### Import[​](#import)

```javascript
import { getNorthWest } from '@mapbox/search-js-core'
```

###### Example

```js
const llb = new 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. This is commonly used as the 'max' point in the bounding box.

###### Returns

[LngLat](#lnglat): The southeast corner of the bounding box.

#### Import[​](#import)

```javascript
import { getSouthEast } from '@mapbox/search-js-core'
```

###### Example

```js
const llb = new 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.

#### Import[​](#import)

```javascript
import { getWest } from '@mapbox/search-js-core'
```

###### Example

```js
const llb = new 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.

#### Import[​](#import)

```javascript
import { getSouth } from '@mapbox/search-js-core'
```

###### Example

```js
const llb = new 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.

#### Import[​](#import)

```javascript
import { getEast } from '@mapbox/search-js-core'
```

###### Example

```js
const llb = new 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.

#### Import[​](#import)

```javascript
import { getNorth } from '@mapbox/search-js-core'
```

###### Example

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

##### toArray()

Returns the bounding box represented as an array.

###### Returns

[[[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)]]: The bounding box represented as an array, consisting of the southwest and northeast coordinates of the bounding represented as arrays of numbers.

#### Import[​](#import)

```javascript
import { toArray } from '@mapbox/search-js-core'
```

###### Example

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

##### toFlatArray()

Returns the bounding box represented as a flattened array.

###### Returns

[[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)]: The bounding box represented as an array of numbers in [west, south, east, north] order.

#### Import[​](#import)

```javascript
import { toFlatArray } from '@mapbox/search-js-core'
```

###### Example

```js
const llb = new LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
llb.toFlatArray(); // = [-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))'` .

#### Import[​](#import)

```javascript
import { toString } from '@mapbox/search-js-core'
```

###### Example

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

このsection on LngLatBoundsは役に立ちましたか？[Yes](null)[No](null)

### LngLatBoundsLike

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

#### Type

([LngLatBounds](#lnglatbounds) \| [[LngLatLike](#lnglatlike), [LngLatLike](#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 LngLatBounds(
  new LngLat(-73.9876, 40.7661),
  new LngLat(-73.9397, 40.8002)
);
const v2 = new LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]);
const v3 = [[-73.9876, 40.7661], [-73.9397, 40.8002]];
```

このsection on LngLatBoundsLikeは役に立ちましたか？[Yes](null)[No](null)

### featureToSuggestion

Utility function to convert the [SearchBoxFeatureSuggestion](https://docs.mapbox.com/mapbox-search-js/ja/mapbox-search-js/api/core/search/#searchboxfeaturesuggestion) properties to a [SearchBoxFeatureProperties](https://docs.mapbox.com/mapbox-search-js/ja/mapbox-search-js/api/core/search/#searchboxfeatureproperties) object.

#### Parameters

| Name | Description |
| --- | --- |
| **feature** ([SearchBoxFeatureSuggestion](https://docs.mapbox.com/mapbox-search-js/ja/mapbox-search-js/api/core/search/#searchboxfeaturesuggestion) \| [AddressAutofillFeatureSuggestion](https://docs.mapbox.com/mapbox-search-js/ja/mapbox-search-js/api/core/autofill/#addressautofillfeaturesuggestion))  |  |

#### Returns

([SearchBoxFeatureProperties](https://docs.mapbox.com/mapbox-search-js/ja/mapbox-search-js/api/core/search/#searchboxfeatureproperties) \| Omit<[AddressAutofillSuggestion](https://docs.mapbox.com/mapbox-search-js/ja/mapbox-search-js/api/core/autofill/#addressautofillsuggestion), (`"original_search_text"` \| `"action"`)>)

このsection on featureToSuggestionは役に立ちましたか？[Yes](null)[No](null)