Esri Provider

For more options and configurations, see the ArcGIS developer docs.

import { EsriProvider } from 'leaflet-geosearch';

const provider = new EsriProvider();

// add to leaflet
import { GeoSearchControl } from 'leaflet-geosearch';

map.addControl(
  new GeoSearchControl({
    provider,
    style: 'bar',
  }),
);

The provider asks for up to 5 locations. Pass maxLocations in params to change that:

const provider = new EsriProvider({ params: { maxLocations: 10 } });

API key

Without a key the provider uses the free geocode.arcgis.com service. With an ArcGIS API key, pass it as token. ArcGIS asks for authenticated requests to go to geocode-api.arcgis.com, so the provider sends them there:

const provider = new EsriProvider({ params: { token: '__YOUR_ARCGIS_KEY__' } });