leaflet
Version:
JavaScript library for mobile-friendly interactive maps
66 lines (65 loc) • 2.54 kB
TypeScript
import { Class } from '../core/Class.js';
import type { ControlDefaults, ControlOptions, Defaults } from '../types.js';
import type { LeafletMap } from '../map/Map.js';
/** @import {ControlDefaults, ControlOptions, Defaults} from '../types.js' */
/** @import {LeafletMap} from '../map/Map.js' */
declare const defaultOptions: {
/**
* The position of the control (one of the map corners). Possible values
* are `'topleft'`, `'topright'`, `'bottomleft'` or `'bottomright'`
* @type {ControlPosition}
*/
position: ControlPosition;
};
export type ControlDefaultsValues = typeof defaultOptions;
export type ControlPosition = 'topleft' | 'topright' | 'bottomleft' | 'bottomright';
/** @typedef {typeof defaultOptions} ControlDefaultsValues */
/**
* One of the map corners a control can be placed in.
* @typedef {'topleft' | 'topright' | 'bottomleft' | 'bottomright'} ControlPosition
*/
/**
* Control is a base class for implementing map controls. Handles
* positioning. All other controls extend from this class.
* @categoryDescription Methods
* Classes extending Control will inherit the following methods:
*
* @categoryDescription Extension methods
* Every control should extend from `Control` and (re-)implement the following methods.
* @template {ControlOptions} [O=ControlOptions]
* @extends {Class<O & ControlDefaults>}
*/
export declare class Control<O extends ControlOptions = ControlOptions> extends Class<O & ControlDefaults> {
_map: LeafletMap;
_container: HTMLElement;
static initHooks: boolean;
/** @type {Defaults<ControlOptions>} */
static defaultOptions: Defaults<ControlOptions>;
/**
* Creates a control with the given options.
* @param {NoInfer<Partial<O>>} [options]
*/
constructor(options?: NoInfer<Partial<O>>);
/** Returns the position of the control. */
getPosition(): "bottomleft" | "bottomright" | "topleft" | "topright";
/**
* Sets the position of the control.
* @param {ControlPosition} position
*/
setPosition(position: ControlPosition): this;
/**
* Returns the HTMLElement that contains the control.
* @returns {HTMLElement | undefined}
*/
getContainer(): HTMLElement | undefined;
/**
* Adds the control to the given map.
* @param {LeafletMap} map
*/
addTo(map: LeafletMap): this;
/** Removes the control from the map it is currently active on. */
remove(): this;
/** @param {MouseEvent} [e] */
_refocusOnMap(e?: MouseEvent): void;
}
export {};