UNPKG

leaflet

Version:

JavaScript library for mobile-friendly interactive maps

143 lines (142 loc) • 5.16 kB
import { Evented } from '../core/Events.js'; import type { Defaults, LayerDefaults, LayerEventMap, LayerOptions, LeafletEvent, PopupEvent, TooltipEvent } from '../types.js'; import type { LeafletMap } from '../map/Map.js'; /** @import {Defaults, LayerDefaults, LayerEventMap, LayerOptions, LeafletEvent, PopupEvent, TooltipEvent} from '../types.js' */ /** @import {LeafletMap} from '../map/Map.js' */ declare const defaultOptions: { /** * By default the layer will be added to the map's [overlay pane](#map-overlaypane). Overriding * this option will cause the layer to be placed on another pane by default. Not effective if * the `renderer` option is set (the `renderer` option will override the `pane` option). */ pane: string; /** * String to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes * the layer data and is often a legal obligation towards copyright holders and tile providers. * @type {string | null} */ attribution: string | null; bubblingPointerEvents: boolean; }; export type LayerDefaultsValues = typeof defaultOptions; export type LayerContainer<L> = { addLayer(layer: L): unknown; removeLayer(layer: L): unknown; }; export type LayerEvents = { /** * Fired after the layer is added to a map */ add: LeafletEvent; /** * Fired after the layer is removed from a map */ remove: LeafletEvent; }; export type LayerPopupEvents = { /** * Fired when a popup bound to this layer is opened */ popupopen: PopupEvent; /** * Fired when a popup bound to this layer is closed */ popupclose: PopupEvent; }; export type LayerTooltipEvents = { /** * Fired when a tooltip bound to this layer is opened. */ tooltipopen: TooltipEvent; /** * Fired when a tooltip bound to this layer is closed. */ tooltipclose: TooltipEvent; }; /** @typedef {typeof defaultOptions} LayerDefaultsValues */ /** * A `LayerGroup` that can hold layers of type `L`: groups type their members as `Layer`, so a popup or a tooltip * isn't one. * @template L * @typedef {{addLayer(layer: L): unknown, removeLayer(layer: L): unknown}} LayerContainer */ /** * @typedef {Object} LayerEvents * @property {LeafletEvent} add Fired after the layer is added to a map * @property {LeafletEvent} remove Fired after the layer is removed from a map */ /** * @category Popup events * @typedef {Object} LayerPopupEvents * @property {PopupEvent} popupopen Fired when a popup bound to this layer is opened * @property {PopupEvent} popupclose Fired when a popup bound to this layer is closed */ /** * @category Tooltip events * @typedef {Object} LayerTooltipEvents * @property {TooltipEvent} tooltipopen Fired when a tooltip bound to this layer is opened. * @property {TooltipEvent} tooltipclose Fired when a tooltip bound to this layer is closed. */ /** * @template {LayerOptions} [O=LayerOptions] * @template {LayerEventMap} [E=LayerEventMap] * @extends {Evented<O & LayerDefaults, E>} */ export declare class LayerBase<O extends LayerOptions = LayerOptions, E extends LayerEventMap = LayerEventMap> extends Evented<O & LayerDefaults, E> { _map: LeafletMap; _zoomAnimated: boolean | undefined; /** @type {Defaults<LayerOptions>} */ static defaultOptions: Defaults<LayerOptions>; /** * Adds the layer to the given map or layer group. * @param {LeafletMap | LayerContainer<this>} map */ addTo(map: LeafletMap | LayerContainer<this>): this; /** Removes the layer from the map it is currently active on. */ remove(): this; /** * Removes the layer from the given map * @overload * @param {LeafletMap} map * @returns {this} */ /** * Removes the layer from the given `LayerGroup` * @overload * @param {LayerContainer<this>} group * @returns {this} */ /** @param {LeafletMap | LayerContainer<this>} [obj] */ removeFrom(map: LeafletMap): this; /** * Removes the layer from the given map * @overload * @param {LeafletMap} map * @returns {this} */ /** * Removes the layer from the given `LayerGroup` * @overload * @param {LayerContainer<this>} group * @returns {this} */ /** @param {LeafletMap | LayerContainer<this>} [obj] */ removeFrom(group: LayerContainer<this>): this; /** * Returns the `HTMLElement` representing the named pane on the * map. If `name` is omitted, returns the pane for this layer. * @param {string} [name] */ getPane(name?: string): HTMLElement; /** @param {HTMLElement | SVGElement} targetEl */ addInteractiveTarget(targetEl: HTMLElement | SVGElement): this; /** @param {HTMLElement | SVGElement} targetEl */ removeInteractiveTarget(targetEl: HTMLElement | SVGElement): this; /** Used by the `attribution control`, returns the [attribution option](#gridlayer-attribution). */ getAttribution(): string | null; /** @param {{target: LeafletMap}} e */ _layerAdd(e: { target: LeafletMap; }): void; } export {};