Photon Provider

Photon is an open-source geocoder for OpenStreetMap data, built for search as you type. It works without an API key.

The public server at photon.komoot.io is free for reasonable use, without guarantees. For heavy traffic, run your own server and point the provider to it with host.

import { PhotonProvider } from 'leaflet-geosearch';

const provider = new PhotonProvider();

// or your own server
const ownProvider = new PhotonProvider({ host: 'https://photon.example.com' });

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

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

Optional parameters

Photon supports parameters like lang, limit, a location bias with lat/lon, or bbox. Pass them in params:

const provider = new PhotonProvider({
  params: {
    lang: 'de', // results in German
    limit: 5,
  },
});