leaflet
Version:
JavaScript library for mobile-friendly interactive maps
35 lines (34 loc) • 1.47 kB
TypeScript
import { Polygon } from './Polygon.js';
import type { InteractiveLayerEventMap, LatLngBoundsExpression, PolylineOptions } from '../../types.js';
/** @import {InteractiveLayerEventMap, LatLngBoundsExpression, PolylineOptions} from '../../types.js' */
/**
* A class for drawing rectangle overlays on a map. Extends `Polygon`.
* @example
* ```js
* // define rectangle geographical bounds
* const bounds = [[54.559322, -5.767822], [56.1210604, -3.021240]];
*
* // create an orange rectangle
* new Rectangle(bounds, {color: "#ff7800", weight: 1}).addTo(map);
*
* // zoom the map to the rectangle bounds
* map.fitBounds(bounds);
* ```
* @template {PolylineOptions} [O=PolylineOptions]
* @template {InteractiveLayerEventMap} [E=InteractiveLayerEventMap]
* @extends {Polygon<O, E>}
*/
export declare class Rectangle<O extends PolylineOptions = PolylineOptions, E extends InteractiveLayerEventMap = InteractiveLayerEventMap> extends Polygon<O, E> {
static initHooks: boolean;
/**
* Instantiates a rectangle object given geographical bounds, and an optional options object.
* @param {LatLngBoundsExpression} latLngBounds
* @param {NoInfer<Partial<O>>} [options]
*/
constructor(latLngBounds: LatLngBoundsExpression, options?: NoInfer<Partial<O>>);
/**
* Redraws the rectangle with the passed bounds.
* @param {LatLngBoundsExpression} latLngBounds
*/
setBounds(latLngBounds: LatLngBoundsExpression): this;
}