A geocoder control for maplibre-gl-js.
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 https://github.com/mapbox/carmen/blob/master/carmen-geojson.md
// View config definitions in our [documentation](https://github.com/maplibre/maplibre-gl-geocoder/blob/master/API.md#setgeocoderapi)
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, { mapboxgl: maplibregl });
It is possible to use the plugin without it being placed as a control on a maplibre-gl map.
See API.md for complete reference.
See CONTRIBUTING.md.