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,
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.
Parameters
(any)
Longitude, measured in degrees.
(any)
Latitude, measured in degrees.
Example
const ll = new LngLat(-123.9749, 40.7736);
console.log(ll.lng); // = -123.9749
Static Members
Instance Members
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
const v1 = new LngLat(-122.420679, 37.772537);
const v2 = [-122.420679, 37.772537];
const v3 = {lon: -122.420679, lat: 37.772537};
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.
Static Members
Instance Members
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]];
featureToSuggestion
Utility function to convert the SearchBoxFeatureSuggestion properties to a SearchBoxFeatureProperties object.
Parameters
Returns
(SearchBoxFeatureProperties | Omit<AddressAutofillSuggestion, ("original_search_text"
| "action"
)>)