import * as L from 'leaflet'; import { IGeocoder, GeocoderOptions, GeocodingResult } from './api'; export type NominatimResponse = NominatimResult[]; export interface NominatimResult { place_id: number; licence: string; osm_type: string; osm_id: number; boundingbox: string[]; lat: string; lon: string; display_name: string; class?: string; type?: string; importance?: number; icon?: string; address: NominatimAddress; } export interface NominatimAddress { building?: string; city_district?: string; city?: string; country_code?: string; country?: string; county?: string; hamlet?: string; house_number?: string; neighbourhood?: string; postcode?: string; road?: string; state_district?: string; state?: string; suburb?: string; village?: string; } export interface NominatimOptions extends GeocoderOptions { /** * Additional URL parameters (strings) that will be added to geocoding requests; can be used to restrict results to a specific country for example, by providing the [`countrycodes`](https://wiki.openstreetmap.org/wiki/Nominatim#Parameters) parameter to Nominatim */ geocodingQueryParams?: Record; /** * A function that takes an GeocodingResult as argument and returns an HTML formatted string that represents the result. Default function breaks up address in parts from most to least specific, in attempt to increase readability compared to Nominatim's naming */ htmlTemplate: (r: NominatimResult) => string; } /** * Implementation of the [Nominatim](https://wiki.openstreetmap.org/wiki/Nominatim) geocoder. * * This is the default geocoding service used by the control, unless otherwise specified in the options. * * Unless using your own Nominatim installation, please refer to the [Nominatim usage policy](https://operations.osmfoundation.org/policies/nominatim/). */ export declare class Nominatim implements IGeocoder { options: NominatimOptions; /** * Start time of the most recent request, as a promise chain, used to space requests apart. */ private _lastRequestStart; /** * Previous responses, by request URL and parameters. */ private _cache; constructor(options?: Partial); /** * Requests `endpoint`, reusing the response of an identical earlier request if there is one. * The usage policy asks to "enable caching of requests", and repeating identical queries may * result in blocking. Failed requests are not cached, so they can be retried. */ private _getJSON; /** * Resolves once the next request may be sent, that is at least * {@link MIN_REQUEST_INTERVAL} after the previous one was started. Callers are queued in * the order they call this, and are delayed rather than dropped. * * Resolves immediately for own installations, as the usage policy only governs * {@link PUBLIC_SERVICE_URL}. Hosts are compared, so that a differing path or trailing * slash still counts as the public service. */ private _rateLimit; geocode(query: string): Promise; /** * Auto-complete is explicitly forbidden by the Nominatim usage policy, which states: * "Auto-complete search — This is not yet supported by Nominatim and you must not * implement such a service on the client side using the API." * * @see https://operations.osmfoundation.org/policies/nominatim/ * @throws {SuggestUnsupportedError} always */ suggest(_query: string): Promise; reverse(location: L.LatLngLiteral, scale: number): Promise<{ name: string; html: string; center: L.LatLng; bbox: L.LatLngBounds; properties: NominatimResult; }[]>; } /** * [Class factory method](https://leafletjs.com/reference.html#class-class-factories) for {@link Nominatim} * @param options the options */ export declare function nominatim(options?: Partial): Nominatim;