@independo/leaflet-independo-maps
Version:
Leaflet plugin for displaying points of interest as pictograms.
98 lines (97 loc) • 3.34 kB
TypeScript
import { LatLngBounds } from "leaflet";
import { PointOfInterestQueryOptions } from "../../models/point-of-interest-query-options";
import { PointOfInterest } from "../../models/point-of-interest";
import { PointOfInterestService } from "../point-of-interest-service";
/**
* Options for configuring the OverpassPOIService.
*/
export interface OverpassPOIServiceOptions {
/**
* The base URL of the Overpass API endpoint.
*
* @default "https://overpass-api.de/api/interpreter".
* @see https://wiki.openstreetmap.org/wiki/Overpass_API#Public_Overpass_API_instances Public Overpass API instances
*/
apiUrl?: string;
/**
* Default types of points of interest to query if none are provided in the {@link PointOfInterestQueryOptions}
* object in the {@link getPointsOfInterest} method.
*
* @default ["shop", "leisure"]
* @see https://wiki.openstreetmap.org/wiki/Key:shop
* @see https://wiki.openstreetmap.org/wiki/Key:leisure
*/
defaultTypes?: string[];
/**
* OpenStreetMap types to query.
* Possible values: "node", "way", "relation".
*
* @default ["node"]
* @see https://wiki.openstreetmap.org/wiki/Elements
*/
osmTypes?: string[];
/**
* Default number of points of interest to query if no limit is provided in the {@link PointOfInterestQueryOptions}
* object in the {@link getPointsOfInterest} method.
*
* @default 25
*/
defaultLimit?: number;
/**
* Maximum number of retries for requests in case of rate limiting or server errors.
*
* @default 3
*/
maxRetries?: number;
/**
* Timeout between retries in milliseconds.
*
* @default 1000
*/
retryDelay?: number;
/**
* Timeout for a single request in seconds.
*
* @default 25
*/
timeout?: number;
/**
* Whether to try to derive names for POIs with no name from their type.
*
* Some POIs may not have a name, but they have a type (e.g., "restaurant"). If this option is enabled,
* the service will try to derive a generic name for the {@link PointOfInterest} from the type (e.g., "Restaurant").
*
* @default true
*/
deriveNames?: boolean;
/**
* Whether to filter out POIs with no name.
*
* If this option is enabled, POIs with no name will be filtered out from the results.
* Otherwise, POIs with no name will be included in the results and will have the name "Unknown".
*
* @default true
*/
filterOutNoName?: boolean;
}
/**
* Implementation of the PointOfInterestService interface using the Overpass API.
*/
export declare class OverpassPOIService implements PointOfInterestService {
private readonly apiUrl;
private readonly defaultTypes;
private readonly osmTypes;
private readonly defaultLimit;
private readonly maxRetries;
private readonly retryDelay;
private readonly timeout;
private readonly deriveNames;
private readonly filterOutNoName;
constructor(options?: OverpassPOIServiceOptions);
/** @inheritDoc */
getPointsOfInterest(bounds: LatLngBounds, options?: PointOfInterestQueryOptions): Promise<PointOfInterest[]>;
private fetchWithRetry;
private processResults;
private buildAddress;
private delay;
}