Skip to main content

Geography and geometry

Public beta for Mapbox Search JS

Mapbox Search JS is in public beta. During the public beta phase, frameworks may be subject to potential changes as they stabilize.

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, 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.

new LngLat(lng: any, lat: any)

Parameters

lng(any)Longitude, measured in degrees.
lat(any)Latitude, measured in degrees.

Example

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

Static Members

Instance Members

Was this section on LngLat helpful?

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.

(LngLat | [number, number] | {lng: number, lat: number} | {lon: number, lat: number})

Example

const v1 = new LngLat(-122.420679, 37.772537);
const v2 = [-122.420679, 37.772537];
const v3 = {lon: -122.420679, lat: 37.772537};
Was this section on LngLatLike helpful?

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 constructs and will perform an implicit conversion. This flexible type is documented as LngLatBoundsLike.

new LngLatBounds()

Static Members

Instance Members

Was this section on LngLatBounds helpful?

LngLatBoundsLike

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

(LngLatBounds | [LngLatLike, LngLatLike] | [number, number, number, number])

Example

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]];
Was this section on LngLatBoundsLike helpful?
Was this section on featureToSuggestion helpful?
Was this page helpful?