项目作者: mapbox

项目描述 :
Geocoder control for mapbox-gl-js using Mapbox Geocoding API
高级语言: JavaScript
项目地址: git://github.com/mapbox/mapbox-gl-geocoder.git
创建时间: 2015-12-14T03:29:56Z
项目社区:https://github.com/mapbox/mapbox-gl-geocoder

开源协议:ISC License

下载


Mapbox GL Geocoder Build Status

A geocoder control for mapbox-gl-js using the Mapbox Geocoding API. For a JavaScript geocoder without a graphical user interface see the Mapbox SDK for JS.

Usage

If you are supporting older browsers, you will need to use a polyfill. We recommend working with @babel/polyfill.

Usage with a module bundler

  1. npm install --save @mapbox/mapbox-gl-geocoder
  1. import MapboxGeocoder from '@mapbox/mapbox-gl-geocoder';
  2. import '@mapbox/mapbox-gl-geocoder/dist/mapbox-gl-geocoder.css';
  3. ...
  4. const geocoder = new MapboxGeocoder({
  5. accessToken: mapboxgl.accessToken,
  6. mapboxgl: mapboxgl
  7. });

Using without a Map

It is possible to use the plugin without it being placed as a control on a mapbox-gl map. Keep in mind that the Mapbox Terms of Service require that POI search results be shown on a Mapbox map. If you don’t need POIs, you can exclude them from your search results with the options.types parameter when constructing a new Geocoder.

Deeper dive

API Documentation

See API.md for complete reference.

Examples

See https://docs.mapbox.com/mapbox-gl-js/examples/#geocoder.

Contributing

See CONTRIBUTING.md.