1. @mapbox/mapbox-gl-geocoder
A geocoder control for Mapbox GL JS
@mapbox/mapbox-gl-geocoder
Package: @mapbox/mapbox-gl-geocoder
Created by: mapbox
Last modified: Fri, 15 Dec 2023 10:48:54 GMT
Version: 5.0.2
License: ISC
Downloads: 356,815
Repository: https://github.com/mapbox/mapbox-gl-geocoder

Install

npm install @mapbox/mapbox-gl-geocoder
yarn add @mapbox/mapbox-gl-geocoder

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

  • https://docs.mapbox.com/mapbox-gl-js/example/mapbox-gl-geocoder/
  • https://docs.mapbox.com/mapbox-gl-js/example/?search=mapbox-gl-geocoder

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

Usage with a module bundler

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

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.

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code