UNPKG

@independo/leaflet-independo-maps

Version:

Leaflet plugin for displaying points of interest as pictograms.

131 lines (130 loc) 5.43 kB
import L from 'leaflet'; import { PictogramMarkerOptions } from "./pictogram-marker"; import { OverpassPOIServiceOptions } from "./services/impl/overpass-poi-service"; import { GlobalSymbolsPictogramServiceOptions } from "./services/impl/global-symbols-p-service"; import { GridSortingServiceOptions } from "./services/impl/grid-sorting-service"; import { PointOfInterestService } from "./services/point-of-interest-service"; import { PictogramService } from "./services/pictogram-service"; import { MarkerSortingService } from "./services/marker-sorting-service"; import { Pictogram } from "./models/pictogram"; /** * Options for configuring the Independo Maps plugin. */ export interface IndependoMapsOptions { /** * Options for the {@link PictogramMarker}s created by the plugin. */ pictogramMarkerOptions?: PictogramMarkerOptions; /** * Options for configuring the default {@link OverpassPOIService}. * * These options are used if no custom `poiService` is provided. * Allows customization of the Overpass API endpoint, default types, and other service-specific behaviors. * * @example * ```typescript * overpassServiceOptions: { * apiUrl: "https://custom-overpass-api.com", * defaultLimit: 50, * defaultTypes: ["amenity", "shop", "tourism"] * }; * ``` */ overpassServiceOptions?: OverpassPOIServiceOptions; /** * Options for configuring the default {@link GlobalSymbolsPictogramService}. * * These options are used if no custom `pictogramService` is provided. * Allows customization of behavior such as including types in display text and symbol set selection. * * @example * ```typescript * globalSymbolsServiceOptions: { * includeTypeInDisplayText: true, * symbolSet: "your-custom-symbolset" * }; * ``` */ globalSymbolsServiceOptions?: GlobalSymbolsPictogramServiceOptions; /** * Options for configuring the default {@link GridSortingService}. * * @remarks This option is used to define the layout direction of the pictograms when adding them to the DOM. * This is relevant for screen readers and keyboard navigation. On the * @example {lr: "lr", tb: "tb"} */ gridSortServiceOptions?: GridSortingServiceOptions; /** * Custom implementation of the {@link PointOfInterestService}. * * Use this field to provide your own service for fetching points of interest (POIs). * If not provided, the plugin will default to an instance of {@link OverpassPOIService}. * * @example * ```typescript * poiService: new CustomPOIService(); * ``` */ poiService?: PointOfInterestService; /** * Custom implementation of the {@link PictogramService}. * * Use this field to provide your own service for fetching pictograms for POIs. * If not provided, the plugin will default to an instance of {@link GlobalSymbolsPictogramService}. * * @example * ```typescript * pictogramService: new CustomPictogramService(); * ``` */ pictogramService?: PictogramService; /** * Custom implementation of the {@link MarkerSortingService}. * * Use this field to provide your own service for sorting markers on the map. * If not provided, the plugin will default to an instance of {@link GridSortingService}. * * @remarks The sorting order does not affect the visual position of the markers on the map, but rather the order in * which they are added to the DOM. This is relevant for screen readers and keyboard navigation. One can imagine * use cases where the markers should be sorted in a specific order, e.g. by distance to the user's location. */ markerSortingService?: MarkerSortingService; /** * Debounce interval in milliseconds for updating the map after a move or zoom event. * * @remarks This interval prevents the map from updating too frequently and causing performance issues. * @default 300 */ debounceInterval?: number; /** * The default pictogram to use when no pictogram is found for a POI. * * @remarks This pictogram will be used when the pictogram service returns `undefined` for a POI. If no pictogram * can be found for a POI and the default pictogram is not provided, the POI will not be displayed on the map. * @default undefined */ defaultPictogram?: Pictogram; } export declare class IndependoMaps { private readonly debounceInterval; private readonly defaultPictogram?; private readonly map; private readonly poiLayerGroup; private readonly poiService; private readonly pictogramService; private readonly markerSortingService; private readonly pictogramMarkerOptions?; constructor(map: L.Map, options?: IndependoMapsOptions); /** * Updates the map by fetching POIs and adding corresponding markers. */ private updateMap; } /** * Initializes the Independo Maps plugin on a {@link L.Map} and returns an instance of the plugin. * * @param map The {@link L.Map} to initialize the plugin on. * @param options Optional {@link IndependoMapsOptions} to configure the plugin. * @returns An instance of {@link IndependoMaps}. */ export declare function initIndependoMaps(map: L.Map, options?: IndependoMapsOptions): IndependoMaps;