メインコンテンツまでスキップ

Geocoding

Geocoding is a custom HTML element that renders a UI search component, allowing users to forward and reverse geocode search and control a Mapbox GL JS map.

This page includes reference documentation for the MapboxGeocoder element, part of the Mapbox Search JS Web framework.

For installation instructions and a helpful introduction to using Address Confirmation in your website or app, see our Web Geocoding Quickstart Guide.

HTML Custom Element

MapboxGeocoder

MapboxGeocoder, also available as the element <mapbox-geocoder>, is an element that lets you search for addresses and places using the Mapbox Geocoding API.

It can control a Mapbox GL JS map to zoom to the selected result.

Additionally, MapboxGeocoder implements the IControl interface.

To use this element, you must have a Mapbox access token.

new MapboxGeocoder()

Example

const search = new MapboxGeocoder();
search.accessToken = 'YOUR_MAPBOX_ACCESS_TOKEN';
map.addControl(search);
<mapbox-geocoder
access-token="YOUR_MAPBOX_ACCESS_TOKEN"
proximity="0,0"
>
</mapbox-geocoder>

Instance Members

Map settings

Methods

Map binding

Events

このsection on MapboxGeocoderは役に立ちましたか?

MapboxGeocoderComponentOptions

Options to configure component-specific Search behavior

Object

Properties

NameDescription
A function accepting the query string which performs supplemental search results on top of those from the Mapbox Geocoding API. Expected to return a Promise which resolves to an array of GeoJSON-like Features as described in the Mapbox Geocoding API .
If true, the coordinates in the query string are expected to be (lat,lng) instead of (lng,lat).

flyTo

(mapboxgl.FlyToOptions | boolean)
If false , animating the map to a selected result is disabled. If true (default), animating the map will use the default animation parameters. If an object, it will be passed as options to the map flyTo method.
このsection on MapboxGeocoderComponentOptionsは役に立ちましたか?
このpageは役に立ちましたか?