UNPKG

map-gl-style-switcher

Version:

A customizable style switcher control for Mapbox GL JS and MapLibre GL JS

53 lines (51 loc) 1.47 kB
type MapInstance = any; interface IControl { onAdd(map: MapInstance): HTMLElement; onRemove(map: MapInstance): void; } interface StyleItem { id: string; name: string; image: string; styleUrl: string; description?: string; } interface StyleSwitcherControlOptions { styles: StyleItem[]; activeStyleId?: string; onBeforeStyleChange?: (from: StyleItem, to: StyleItem) => void; onAfterStyleChange?: (from: StyleItem, to: StyleItem) => void; showLabels?: boolean; showImages?: boolean; animationDuration?: number; maxHeight?: number; theme?: 'light' | 'dark' | 'auto'; classNames?: Partial<StyleSwitcherClassNames>; rtl?: boolean; } interface StyleSwitcherClassNames { container: string; list: string; item: string; itemSelected: string; itemHideLabel: string; dark: string; light: string; } declare class StyleSwitcherControl implements IControl { private _container; private _options; private _activeStyleId; private _expanded; private _classNames; constructor(options: StyleSwitcherControlOptions); onAdd(_map: MapInstance): HTMLElement; private _applyTheme; onRemove(): void; private _setExpanded; private _handleStyleChange; private _render; private _createStyleItem; } export { StyleSwitcherControl as a }; export type { IControl as I, StyleSwitcherControlOptions as S, StyleItem as b, StyleSwitcherClassNames as c };