Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@maplibre/maplibre-gl-geocoder

maplibre137.9kISC1.8.0TypeScript support: included

A geocoder control for Maplibre GL JS

geocoder, osm, gl

readme

MapLibre GL Geocoder

A geocoder control for maplibre-gl-js.

Usage

A full working example can be found here, which uses Nominatim: https://maplibre.org/maplibre-gl-js/docs/examples/geocoder/

Usage with a module bundler

npm install --save @maplibre/maplibre-gl-geocoder
import MaplibreGeocoder from '@maplibre/maplibre-gl-geocoder';
import '@maplibre/maplibre-gl-geocoder/dist/maplibre-gl-geocoder.css';
...
// Functions should return Carmen GeoJSON, see the relevant type in this project
// View config definitions in our [documentation](https://www.maplibre.org/maplibre-gl-geocoder/)
var Geo = {
  // required
  forwardGeocode: async (config) => { /* definition here */ },

  // optional
  reverseGeocode: async (config) => { /* definition here */ }, // reverse geocoding API
  getSuggestions: async (config) => { /* definition here */ }, // suggestion API
  searchByPlaceId: async (config) => { /* definition here */ } // search by Place ID API
};

// Pass in or define a geocoding API that matches the above
const geocoder = new MaplibreGeocoder(Geo, { maplibregl: maplibregl });
map.addControl(geocoder);

Using without a Map

It is possible to use the plugin without it being placed as a control on a maplibre-gl map.

Deeper dive

API Documentation

See here for complete reference.

Also check out the example in MapLibre docs: https://maplibre.org/maplibre-gl-js/docs/examples/geocoder/

Contributing

See CONTRIBUTING.md.

Licence

ISC © MapLibre © Mapbox

changelog

main

Features / Improvements 🚀

Bug fixes 🐛

1.8.0

Features / Improvements 🚀

Bug fixes 🐛

1.7.1

Features / Improvements 🚀

Bug fixes 🐛

1.7.0

Features / Improvements 🚀

Bug fixes 🐛

1.6.0

Features / Improvements 🚀

Bug fixes 🐛

1.5.0

Features / Improvements 🚀

  • Update suggestions API to support placeId #84

1.4.2

Features / Improvements 🚀

Bug fixes 🐛

  • fix: fix bug with fitbounds array, fix bug where clearbutton doesnt show up after pressing enter #79

1.4.1

Features / Improvements 🚀

Bug fixes 🐛

1.4.0

Features / Improvements 🚀

  • accept any version of MapLibre GL JS greater or equal to 1.14.0 #49

Bug fixes 🐛

1.3.1

Features / Improvements 🚀

  • N/A

Bug fixes 🐛

  • update vulnerable version of nanoid to 3.2.0 #35
  • remove yarn.lock and prefer using package-lock.json #40

1.3.0

Features / Improvements 🚀

  • Added suggestions API and UI around display suggestions #27

Bug fixes 🐛

  • N/A

1.2.0

Features / Improvements 🚀

  • Switch from suggestions library to suggestions-list, change enter key logic to support selecting list items with enter key #14
  • Added debounce option #15

Bug fixes 🐛

  • Use the correct debounce parameter #13

1.1.1

Features / Improvements 🚀

  • Add optional debounceSearch parameter to decide how long to wait before sending Geocoder input box query to server

Bug fixes 🐛

  • N/A

1.1.0

Features / Improvements 🚀

  • Updated Geocoder to by default only perform search on enter key press, added option to search when typing #5

Bug fixes 🐛

  • create cloned html element for multiple marker results #6

1.0.0

Features / Improvements 🚀

  • Initial Launch of forked maplibre-gl-geocoder from mapbox-gl-geocoder

Bug fixes 🐛

  • N/A