UNPKG

leaflet

Version:

JavaScript library for mobile-friendly interactive maps

63 lines (62 loc) • 2.74 kB
import { LayerGroup } from './LayerGroup.js'; import { LatLngBounds } from '../geo/LatLngBounds.js'; import type { FeatureGroupEventMap, InteractiveLayerOptions, LayerEvent } from '../types.js'; import type { Layer } from './Layer.js'; export type FeatureGroupEvents = { /** * Fired when a layer is added to this `FeatureGroup` */ layeradd: LayerEvent; /** * Fired when a layer is removed from this `FeatureGroup` */ layerremove: LayerEvent; }; /** @import {FeatureGroupEventMap, InteractiveLayerOptions, LayerEvent} from '../types.js' */ /** @import {Layer} from './Layer.js' */ /** @import {LayerBase} from './LayerBase.js' */ /** * @typedef {Object} FeatureGroupEvents * @property {LayerEvent} layeradd Fired when a layer is added to this `FeatureGroup` * @property {LayerEvent} layerremove Fired when a layer is removed from this `FeatureGroup` */ /** * Extended `LayerGroup` that makes it easier to do the same thing to all its member layers: * * [`bindPopup`](#layer-bindpopup) binds a popup to all of the layers at once (likewise with [`bindTooltip`](#layer-bindtooltip)) * * Events are propagated to the `FeatureGroup`, so if the group has an event * handler, it will handle events from any of the layers. This includes pointer events and custom events. * * Has `layeradd` and `layerremove` events * @example * ```js * new FeatureGroup([marker1, marker2, polyline]) * .bindPopup('Hello world!') * .on('click', function() { alert('Clicked on a member of the group!'); }) * .addTo(map); * ``` * @template {Layer} [L=Layer] * @template {InteractiveLayerOptions} [O=InteractiveLayerOptions] * @template {FeatureGroupEventMap} [E=FeatureGroupEventMap] * @extends {LayerGroup<L, O, E>} */ export declare class FeatureGroup<L extends Layer = Layer, O extends InteractiveLayerOptions = InteractiveLayerOptions, E extends FeatureGroupEventMap = FeatureGroupEventMap> extends LayerGroup<L, O, E> { /** @param {L} layer */ addLayer(layer: L): this; /** @param {L | number} layer */ removeLayer(layer: L | number): this; /** * Sets the given path options to each layer of the group that has a `setStyle` method. * @param {object} style */ setStyle(style: object): this; /** Brings the layer group to the top of all other layers */ bringToFront(): this; /** Brings the layer group to the back of all other layers */ bringToBack(): this; /** * Returns the LatLngBounds of the Feature Group (created from bounds and coordinates * of its children, including the layers of nested layer groups). */ getBounds(): LatLngBounds; /** @returns {Layer | undefined} */ _getOverlaySource(): Layer | undefined; }