OpenStreetMap Provider
For more options and configurations, see the OpenStreetMap Nominatim wiki.
import { OpenStreetMapProvider } from 'leaflet-geosearch';const provider = new OpenStreetMapProvider();// add to leafletimport { GeoSearchControl } from 'leaflet-geosearch';map.addControl(new GeoSearchControl({provider,style: 'bar',}),);
Authentication
Note that OpenStreetMap is open, but not free without limits. They do have a Usage Policy just like the other providers. Provide the email
property to opt-in for authenticated requests.
const provider = new OpenStreetMapProvider({params: {email: 'john@example.com', // auth for large number of requests},});
Optional parameters
OpenStreetMap Nominatim supports a number of optional parameters. As the api requires those parameters to be added to the url, they can be added to the params
key of the provider.
All options defined next to the params
key, would have been added to the request body.
const provider = new OpenStreetMapProvider({params: {'accept-language': 'nl', // render results in Dutchcountrycodes: 'nl', // limit search results to the Netherlandsaddressdetails: 1, // include additional address detail parts},});