Skip to main content

Geocoding

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.

GeocodingCore

A GeocodingCore object is an application's main entrypoint to the Mapbox Geocoding API. The Geocoding API allows forward (location to coordinates) and reverse (coordinates to location) queries, enabled by corresponding methods from the GeocodingCore object.

A Mapbox access token is required to use GeocodingCore, and other options may be specified either in the constructor or in the GeocodingCore#forward or GeocodingCore#reverse calls.

new GeocodingCore(options: GeocodingOptions?)

Parameters

options(GeocodingOptions?)
NameDescription
options.accessToken
string?

Example

const geocode = new GeocodingCore({ accessToken: 'pk.my-mapbox-access-token' });

const results = await geocode.forward('Washington D.C.');
if (results.features.length === 0) return;

const feature = results.features[0];
doSomethingWithCoordinates(feature);

Instance Members

Was this section on GeocodingCore helpful?

GeocodingOptions

Instance Members

Was this section on GeocodingOptions helpful?

GeocodingResponse

A GeocodingResponse object represents a returned data object from the Mapbox Geocoding API.

Instance Members

Was this section on GeocodingResponse helpful?

GeocodingFeature

A GeocodingFeature object represents a GeoJSON feature result from the Mapbox Geocoding API.

Legal terms:

Due to legal terms from our data sources, results from the Mapbox Geocoding API should use the permanent=true flag if the results are to be cached/stored in a customer database. Otherwise, results should be used ephemerally and not persisted.

This permanent policy is consistent with the Mapbox Terms of Service and failure to comply may result in modified or discontinued service.

Additionally, the Mapbox Terms of Service states any rendering of a feature suggestion must be using Mapbox map services (for example, displaying results on Google Maps or MapKit JS is not allowed).

Disclaimer:

The failure of Mapbox to exercise or enforce any right or provision of these Terms will not constitute a waiver of such right or provision.

any

Static Members

Was this section on GeocodingFeature helpful?

GeocodingFeatureProperties

Raw GeoJSON feature properties from the Mapbox Geocoding API.

Reference: https://docs.mapbox.com/api/search/geocoding-v6/#geocoding-response-object

Instance Members

Was this section on GeocodingFeatureProperties helpful?
Was this section on GeocodingFeatureContext helpful?

GeocodingFeatureContextComponent

Object representing one level of hierarcy among encompassing parent features for a given GeocodingFeature.

Instance Members

Was this section on GeocodingFeatureContextComponent helpful?

FeatureTypes

Geographic feature data types for the Mapbox Geocoding API.

("country" | "region" | "postcode" | "district" | "place" | "locality" | "neighborhood" | "street" | "block" | "address" | "secondary_address")
Was this section on FeatureTypes helpful?

Coordinates

Coordinate and accuracy data for a geographic feature.

Instance Members

Was this section on Coordinates helpful?

RoutablePoint

Routable point data for an address feature.

Instance Members

Was this section on RoutablePoint helpful?
Was this page helpful?