Geocode Earth Provider

Geocode Earth is a hosted version of Pelias run by the core maintainers of the FOSS project.

note: Geocode Earth services require an API key, grab a free trial key from their website.

For more options and configurations, see the documentation.

import { GeocodeEarthProvider } from 'leaflet-geosearch';

// grab an API key from https://geocode.earth
const provider = new GeocodeEarthProvider({
  params: {
    api_key: '__YOUR_GEOCODE_EARTH_KEY__',
  },
});

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

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

Optional parameters

Geocode Earth supports a wide range of number of optional parameters which can be applied to every request using the params object:

const provider = new GeocodeEarthProvider({
  params: {
    size: 5, // limit the total number of results returned
    lang: 'nl', // render results in Dutch
    'boundary.country': 'NL', // limit search results to the Netherlands
    layers: 'address,street', // limmit which layers are queried
  },
});

Or individually on a per-request basis:

const results = await provider.search({
  query: {
    text: 'example',
    'focus.point.lat': 1.11, // score results nearer to the focus point higher
    'focus.point.lon': 2.22,
  },
});