typescript-closure-tools
Version:
Command-line tools to convert closure-style JSDoc annotations to typescript, and to convert typescript sources to closure externs files
1,598 lines (1,272 loc) • 126 kB
TypeScript
// Type definitions for Leaflet.js 0.6.4
// Project: https://github.com/Leaflet/Leaflet
// Definitions by: Vladimir Zotov <https://github.com/rgripper>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module L {
export interface AttributionOptions {
/**
* The position of the control (one of the map corners). See control positions.
* Default value: 'bottomright'.
*/
position?: string;
/**
* The HTML text shown before the attributions. Pass false to disable.
* Default value: 'Powered by Leaflet'.
*/
prefix?: string;
}
}
declare module L {
/**
* Creates a Bounds object from two coordinates (usually top-left and bottom-right
* corners).
*/
export function bounds(topLeft: Point, bottomRight: Point): Bounds;
/**
* Creates a Bounds object defined by the points it contains.
*/
export function bounds(points: Point[]): Bounds;
export class Bounds {
/**
* Creates a Bounds object from two coordinates (usually top-left and bottom-right
* corners).
*/
constructor(topLeft: Point, bottomRight: Point);
/**
* Creates a Bounds object defined by the points it contains.
*/
constructor(points: Point[]);
/**
* Extends the bounds to contain the given point.
*/
extend(point: Point): void;
/**
* Returns the center point of the bounds.
*/
getCenter(): Point;
/**
* Returns true if the rectangle contains the given one.
*/
contains(otherBounds: Bounds): boolean;
/**
* Returns true if the rectangle contains the given point.
*/
contains(point: Point): boolean;
/**
* Returns true if the rectangle intersects the given bounds.
*/
intersects(otherBounds: Bounds): boolean;
/**
* Returns true if the bounds are properly initialized.
*/
isValid(): boolean;
/**
* Returns the size of the given bounds.
*/
getSize(): Point;
/**
* The top left corner of the rectangle.
*/
min: Point;
/**
* The bottom right corner of the rectangle.
*/
max: Point;
}
}
declare module L {
export class Browser {
/**
* true for all Internet Explorer versions.
*/
static ie: boolean;
/**
* true for Internet Explorer 6.
*/
static ie6: boolean;
/**
* true for Internet Explorer 6.
*/
static ie7: boolean;
/**
* true for webkit-based browsers like Chrome and Safari (including mobile
* versions).
*/
static webkit: boolean;
/**
* true for webkit-based browsers that support CSS 3D transformations.
*/
static webkit3d: boolean;
/**
* true for Android mobile browser.
*/
static android: boolean;
/**
* true for old Android stock browsers (2 and 3).
*/
static android23: boolean;
/**
* true for modern mobile browsers (including iOS Safari and different Android
* browsers).
*/
static mobile: boolean;
/**
* true for mobile webkit-based browsers.
*/
static mobileWebkit: boolean;
/**
* true for mobile Opera.
*/
static mobileOpera: boolean;
/**
* true for all browsers on touch devices.
*/
static touch: boolean;
/**
* true for browsers with Microsoft touch model (e.g. IE10).
*/
static msTouch: boolean;
/**
* true for devices with Retina screens.
*/
static retina: boolean;
}
}
declare module L {
/**
* Instantiates a circle object given a geographical point, a radius in meters
* and optionally an options object.
*/
function circle(latlng: LatLng, radius: number, options?: PathOptions): Circle;
export class Circle extends Path {
/**
* Instantiates a circle object given a geographical point, a radius in meters
* and optionally an options object.
*/
constructor(latlng: LatLng, radius: number, options?: PathOptions);
/**
* Returns the current geographical position of the circle.
*/
getLatLng(): LatLng;
/**
* Returns the current radius of a circle. Units are in meters.
*/
getRadius(): number;
/**
* Sets the position of a circle to a new location.
*/
setLatLng(latlng: LatLng): Circle;
/**
* Sets the radius of a circle. Units are in meters.
*/
setRadius(radius: number): Circle;
/**
* Returns a GeoJSON representation of the circle (GeoJSON Point Feature).
*/
toGeoJSON(): any;
}
}
declare module L {
/**
* Instantiates a circle marker given a geographical point and optionally
* an options object. The default radius is 10 and can be altered by passing a
* "radius" member in the path options object.
*/
function circleMarker(latlng: LatLng, options?: PathOptions): CircleMarker;
export class CircleMarker extends Circle {
/**
* Instantiates a circle marker given a geographical point and optionally
* an options object. The default radius is 10 and can be altered by passing a
* "radius" member in the path options object.
*/
constructor(latlng: LatLng, options?: PathOptions);
/**
* Sets the position of a circle marker to a new location.
*/
setLatLng(latlng: LatLng): CircleMarker;
/**
* Sets the radius of a circle marker. Units are in pixels.
*/
setRadius(radius: number): CircleMarker;
/**
* Returns a GeoJSON representation of the circle marker (GeoJSON Point Feature).
*/
toGeoJSON(): any;
}
}
declare module L {
export interface ClassExtendOptions {
/**
* options is a special property that unlike other objects that you pass
* to extend will be merged with the parent one instead of overriding it
* completely, which makes managing configuration of objects and default
* values convenient.
*/
options?: any;
/**
* includes is a special class property that merges all specified objects
* into the class (such objects are called mixins). A good example of this
* is L.Mixin.Events that event-related methods like on, off and fire
* to the class.
*/
includes?: any;
/**
* statics is just a convenience property that injects specified object
* properties as the static properties of the class, useful for defining
* constants.
*/
static?: any;
}
/**
* L.Class powers the OOP facilities of Leaflet and is used to create
* almost all of the Leaflet classes documented.
*/
export class Class {
/**
* You use L.Class.extend to define new classes, but you can use the
* same method on any class to inherit from it.
*/
static extend(options: ClassExtendOptions): any;
/**
* You can also use the following shortcut when you just need to make
* one additional method call.
*/
static addInitHook(methodName: string, ...args: any[]): void;
}
}
declare module L {
export class Control extends Class implements IControl {
/**
* Creates a control with the given options.
*/
constructor(options?: ControlOptions);
/**
* Sets the position of the control. See control positions.
*/
setPosition(position: string): Control;
/**
* Returns the current position of the control.
*/
getPosition(): string;
/**
* Adds the control to the map.
*/
addTo(map: Map): Control;
/**
* Removes the control from the map.
*/
removeFrom(map: Map): Control;
/**
* Returns the HTML container of the control.
*/
getContainer(): HTMLElement;
// IControl members
/**
* Should contain code that creates all the neccessary DOM elements for the
* control, adds listeners on relevant map events, and returns the element
* containing the control. Called on map.addControl(control) or control.addTo(map).
*/
onAdd(map: Map): HTMLElement;
/**
* Optional, should contain all clean up code (e.g. removes control's event
* listeners). Called on map.removeControl(control) or control.removeFrom(map).
* The control's DOM container is removed automatically.
*/
onRemove(map: Map): void;
}
module Control {
export class Zoom extends L.Control {
/**
* Creates a zoom control.
*/
constructor(options?: ZoomOptions);
}
export class Attribution extends L.Control {
/**
* Creates an attribution control.
*/
constructor(options?: AttributionOptions);
/**
* Sets the text before the attributions.
*/
setPrefix(prefix: string): Attribution;
/**
* Adds an attribution text (e.g. 'Vector data © CloudMade').
*/
addAttribution(text: string): Attribution;
/**
* Removes an attribution text.
*/
removeAttribution(text: string): Attribution;
}
export class Layers extends L.Control implements IEventPowered<Layers> {
/**
* Creates an attribution control with the given layers. Base layers will be
* switched with radio buttons, while overlays will be switched with checkboxes.
*/
constructor(baseLayers?: any, overlays?: any, options?: LayersOptions);
/**
* Adds a base layer (radio button entry) with the given name to the control.
*/
addBaseLayer(layer: ILayer, name: string): Layers;
/**
* Adds an overlay (checkbox entry) with the given name to the control.
*/
addOverlay(layer: ILayer, name: string): Layers;
/**
* Remove the given layer from the control.
*/
removeLayer(layer: ILayer): Layers;
////////////////
////////////////
addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Layers;
addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Layers;
removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): Layers;
hasEventListeners(type: string): boolean;
fireEvent(type: string, data?: any): Layers;
on(type: string, fn: (e: LeafletEvent) => void, context?: any): Layers;
once(type: string, fn: (e: LeafletEvent) => void, context?: any): Layers;
off(type: string, fn?: (e: LeafletEvent) => void, context?: any): Layers;
fire(type: string, data?: any): Layers; addEventListener(eventMap: any, context?: any): Layers;
removeEventListener(eventMap?: any, context?: any): Layers;
clearAllEventListeners(): Layers;
on(eventMap: any, context?: any): Layers;
off(eventMap?: any, context?: any): Layers;
}
export class Scale extends L.Control {
/**
* Creates an scale control with the given options.
*/
constructor(options?: ScaleOptions);
}
}
export class control {
/**
* Creates a control with the given options.
*/
function (options?: ControlOptions): Control;
/**
* Creates a zoom control.
*/
static zoom(options?: ZoomOptions): L.Control.Zoom;
/**
* Creates an attribution control.
*/
static attribution(options?: AttributionOptions): L.Control.Attribution;
/**
* Creates an attribution control with the given layers. Base layers will be
* switched with radio buttons, while overlays will be switched with checkboxes.
*/
static layers(baseLayers?: any, overlays?: any, options?: LayersOptions): L.Control.Layers;
/**
* Creates an scale control with the given options.
*/
static scale(options?: ScaleOptions): L.Control.Scale;
}
}
declare module L {
export interface ControlOptions {
/**
* The initial position of the control (one of the map corners). See control
* positions.
* Default value: 'topright'.
*/
position: string;
}
}
declare module L {
export class CRS {
/**
* The most common CRS for online maps, used by almost all free and commercial
* tile providers. Uses Spherical Mercator projection. Set in by default in
* Map's crs option.
*/
static EPSG3857: ICRS;
/**
* A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.
*/
static EPSG4326: ICRS;
/**
* Rarely used by some commercial tile providers. Uses Elliptical Mercator
* projection.
*/
static EPSG3395: ICRS;
/**
* A simple CRS that maps longitude and latitude into x and y directly. May be
* used for maps of flat surfaces (e.g. game maps). Note that the y axis should
* still be inverted (going from bottom to top).
*/
static Simple: ICRS;
}
}
declare module L {
/**
* Creates a div icon instance with the given options.
*/
function divIcon(options: DivIconOptions): DivIcon;
export class DivIcon extends Icon {
/**
* Creates a div icon instance with the given options.
*/
constructor(options: DivIconOptions);
}
}
declare module L {
export interface DivIconOptions {
/**
* Size of the icon in pixels. Can be also set through CSS.
*/
iconSize?: Point;
/**
* The coordinates of the "tip" of the icon (relative to its top left corner).
* The icon will be aligned so that this point is at the marker's geographical
* location. Centered by default if size is specified, also can be set in CSS
* with negative margins.
*/
iconAnchor?: Point;
/**
* A custom class name to assign to the icon.
*
* Default value: 'leaflet-div-icon'.
*/
className?: string;
/**
* A custom HTML code to put inside the div element.
*
* Default value: ''.
*/
html?: string;
}
}
declare module L {
export class DomEvent {
/**
* Adds a listener fn to the element's DOM event of the specified type. this keyword
* inside the listener will point to context, or to the element if not specified.
*/
static addListener(el: HTMLElement, type: string, fn: (e: Event) => void, context?: any): DomEvent;
/**
* Removes an event listener from the element.
*/
static removeListener(el: HTMLElement, type: string, fn: (e: Event) => void): DomEvent;
/**
* Stop the given event from propagation to parent elements. Used inside the
* listener functions:
* L.DomEvent.addListener(div, 'click', function
* (e) {
* L.DomEvent.stopPropagation(e);
* });
*/
static stopPropagation(e: Event): DomEvent;
/**
* Prevents the default action of the event from happening (such as following
* a link in the href of the a element, or doing a POST request with page reload
* when form is submitted). Use it inside listener functions.
*/
static preventDefault(e: Event): DomEvent;
/**
* Does stopPropagation and preventDefault at the same time.
*/
static stop(e: Event): DomEvent;
/**
* Adds stopPropagation to the element's 'click', 'doubleclick', 'mousedown'
* and 'touchstart' events.
*/
static disableClickPropagation(el: HTMLElement): DomEvent;
/**
* Gets normalized mouse position from a DOM event relative to the container
* or to the whole page if not specified.
*/
static getMousePosition(e: Event, container?: HTMLElement): Point;
/**
* Gets normalized wheel delta from a mousewheel DOM event.
*/
static getWheelDelta(e: Event): number;
}
}
declare module L {
export class DomUtil {
/**
* Returns an element with the given id if a string was passed, or just returns
* the element if it was passed directly.
*/
static get(id: string): HTMLElement;
/**
* Returns the value for a certain style attribute on an element, including
* computed values or values set through CSS.
*/
static getStyle(el: HTMLElement, style: string): string;
/**
* Returns the offset to the viewport for the requested element.
*/
static getViewportOffset(el: HTMLElement): Point;
/**
* Creates an element with tagName, sets the className, and optionally appends
* it to container element.
*/
static create(tagName: string, className: string, container?: HTMLElement): HTMLElement;
/**
* Makes sure text cannot be selected, for example during dragging.
*/
static disableTextSelection(): void;
/**
* Makes text selection possible again.
*/
static enableTextSelection(): void;
/**
* Returns true if the element class attribute contains name.
*/
static hasClass(el: HTMLElement, name: string): boolean;
/**
* Adds name to the element's class attribute.
*/
static addClass(el: HTMLElement, name: string): void;
/**
* Removes name from the element's class attribute.
*/
static removeClass(el: HTMLElement, name: string): void;
/**
* Set the opacity of an element (including old IE support). Value must be from
* 0 to 1.
*/
static setOpacity(el: HTMLElement, value: number): void;
/**
* Goes through the array of style names and returns the first name that is a valid
* style name for an element. If no such name is found, it returns false. Useful
* for vendor-prefixed styles like transform.
*/
static testProp(props: string[]): any;
/**
* Returns a CSS transform string to move an element by the offset provided in
* the given point. Uses 3D translate on WebKit for hardware-accelerated transforms
* and 2D on other browsers.
*/
static getTranslateString(point: Point): string;
/**
* Returns a CSS transform string to scale an element (with the given scale origin).
*/
static getScaleString(scale: number, origin: Point): string;
/**
* Sets the position of an element to coordinates specified by point, using
* CSS translate or top/left positioning depending on the browser (used by
* Leaflet internally to position its layers). Forces top/left positioning
* if disable3D is true.
*/
static setPosition(el: HTMLElement, point: Point, disable3D?: boolean): void;
/**
* Returns the coordinates of an element previously positioned with setPosition.
*/
static getPosition(el: HTMLElement): Point;
/**
* Vendor-prefixed transition style name (e.g. 'webkitTransition' for WebKit).
*/
static TRANSITION: string;
/**
* Vendor-prefixed transform style name.
*/
static TRANSFORM: string;
}
}
declare module L {
/**
* Creates a Draggable object for moving the given element when you start dragging
* the dragHandle element (equals the element itself by default).
*/
function draggable(element: HTMLElement, dragHandle?: HTMLElement): Draggable;
export class Draggable extends Class implements IEventPowered<Draggable> {
/**
* Creates a Draggable object for moving the given element when you start dragging
* the dragHandle element (equals the element itself by default).
*/
constructor(element: HTMLElement, dragHandle?: HTMLElement);
/**
* Enables the dragging ability.
*/
enable(): void;
/**
* Disables the dragging ability.
*/
disable(): void;
////////////////
////////////////
addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Draggable;
addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): Draggable;
removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): Draggable;
hasEventListeners(type: string): boolean;
fireEvent(type: string, data?: any): Draggable;
on(type: string, fn: (e: LeafletEvent) => void, context?: any): Draggable;
once(type: string, fn: (e: LeafletEvent) => void, context?: any): Draggable;
off(type: string, fn?: (e: LeafletEvent) => void, context?: any): Draggable;
fire(type: string, data?: any): Draggable;
addEventListener(eventMap: any, context?: any): Draggable;
removeEventListener(eventMap?: any, context?: any): Draggable;
clearAllEventListeners(): Draggable;
on(eventMap: any, context?: any): Draggable;
off(eventMap?: any, context?: any): Draggable;
}
}
declare module L {
/**
* Create a layer group, optionally given an initial set of layers.
*/
function featureGroup(layers?: ILayer[]): FeatureGroup;
export class FeatureGroup extends LayerGroup implements ILayer, IEventPowered<FeatureGroup> {
/**
* Create a layer group, optionally given an initial set of layers.
*/
constructor(layers?: ILayer[]);
/**
* Binds a popup with a particular HTML content to a click on any layer from the
* group that has a bindPopup method.
*/
bindPopup(htmlContent: string, options?: PopupOptions): FeatureGroup;
/**
* Returns the LatLngBounds of the Feature Group (created from bounds and coordinates
* of its children).
*/
getBounds(): LatLngBounds;
/**
* Sets the given path options to each layer of the group that has a setStyle method.
*/
setStyle(style: PathOptions): FeatureGroup;
/**
* Brings the layer group to the top of all other layers.
*/
bringToFront(): FeatureGroup;
/**
* Brings the layer group to the bottom of all other layers.
*/
bringToBack(): FeatureGroup;
////////////
////////////
/**
* Should contain code that creates DOM elements for the overlay, adds them
* to map panes where they should belong and puts listeners on relevant map events.
* Called on map.addLayer(layer).
*/
onAdd(map: Map): void;
/**
* Should contain all clean up code that removes the overlay's elements from
* the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).
*/
onRemove(map: Map): void;
////////////////
////////////////
addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): FeatureGroup;
addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): FeatureGroup;
removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): FeatureGroup;
hasEventListeners(type: string): boolean;
fireEvent(type: string, data?: any): FeatureGroup;
on(type: string, fn: (e: LeafletEvent) => void, context?: any): FeatureGroup;
once(type: string, fn: (e: LeafletEvent) => void, context?: any): FeatureGroup;
off(type: string, fn?: (e: LeafletEvent) => void, context?: any): FeatureGroup;
fire(type: string, data?: any): FeatureGroup;
addEventListener(eventMap: any, context?: any): FeatureGroup;
removeEventListener(eventMap?: any, context?: any): FeatureGroup;
clearAllEventListeners(): FeatureGroup;
on(eventMap: any, context?: any): FeatureGroup;
off(eventMap?: any, context?: any): FeatureGroup;
}
}
declare module L {
export interface FitBoundsOptions extends ZoomPanOptions {
/**
* Sets the amount of padding in the top left corner of a map container that
* shouldn't be accounted for when setting the view to fit bounds. Useful if
* you have some control overlays on the map like a sidebar and you don't
* want them to obscure objects you're zooming to.
*
* Default value: [0, 0].
*/
paddingTopLeft?: Point;
/**
* The same for bottom right corner of the map.
*
* Default value: [0, 0].
*/
paddingBottomRight?: Point;
/**
* Equivalent of setting both top left and bottom right padding to the same value.
*
* Default value: [0, 0].
*/
padding?: Point;
}
}
declare module L {
/**
* Creates a GeoJSON layer. Optionally accepts an object in GeoJSON format
* to display on the map (you can alternatively add it later with addData method)
* and an options object.
*/
function geoJson(geojson?: any, options?: GeoJSONOptions): GeoJSON;
export class GeoJSON extends FeatureGroup {
/**
* Creates a GeoJSON layer. Optionally accepts an object in GeoJSON format
* to display on the map (you can alternatively add it later with addData method)
* and an options object.
*/
constructor(geojson?: any, options?: GeoJSONOptions);
/**
* Adds a GeoJSON object to the layer.
*/
addData(data: any): boolean;
/**
* Changes styles of GeoJSON vector layers with the given style function.
*/
setStyle(style: (featureData: any) => any): GeoJSON;
/**
* Resets the the given vector layer's style to the original GeoJSON style,
* useful for resetting style after hover events.
*/
resetStyle(layer: Path): GeoJSON;
/**
* Creates a layer from a given GeoJSON feature.
*/
static geometryToLayer(featureData: GeoJSON, pointToLayer?: (featureData: any, latlng: LatLng) => ILayer): ILayer;
/**
* Creates a LatLng object from an array of 2 numbers (latitude, longitude)
* used in GeoJSON for points. If reverse is set to true, the numbers will be interpreted
* as (longitude, latitude).
*/
static coordsToLatlng(coords: number[], reverse?: boolean): LatLng;
/**
* Creates a multidimensional array of LatLng objects from a GeoJSON coordinates
* array. levelsDeep specifies the nesting level (0 is for an array of points,
* 1 for an array of arrays of points, etc., 0 by default). If reverse is set to
* true, the numbers will be interpreted as (longitude, latitude).
*/
static coordsToLatlngs(coords: number[], levelsDeep?: number, reverse?: boolean): LatLng[];
}
}
declare module L {
export interface GeoJSONOptions {
/**
* Function that will be used for creating layers for GeoJSON points (if not
* specified, simple markers will be created).
*/
pointToLayer?: (featureData: any, latlng: LatLng) => ILayer;
/**
* Function that will be used to get style options for vector layers created
* for GeoJSON features.
*/
style?: (featureData: any) => any;
/**
* Function that will be called on each created feature layer. Useful for attaching
* events and popups to features.
*/
onEachFeature?: (featureData: any, layer: ILayer) => void;
/**
* Function that will be used to decide whether to show a feature or not.
*/
filter?: (featureData: any, layer: ILayer) => boolean;
/**
* Function that will be used for converting GeoJSON coordinates to LatLng points
* (if not specified, coords will be assumed to be WGS84 � standard[longitude, latitude]
* values in degrees).
*/
coordsToLatLng?: (coords: any[]) => LatLng[];
}
}
declare module L {
/**
* Creates an icon instance with the given options.
*/
function icon(options: IconOptions): Icon;
export class Icon extends Class {
/**
* Creates an icon instance with the given options.
*/
constructor(options: IconOptions);
}
module Icon {
/**
* L.Icon.Default extends L.Icon and is the blue icon Leaflet uses
* for markers by default.
*/
export class Default extends Icon {
/**
* Creates a default icon instance with the given options.
*/
constructor(options?: IconOptions);
static imagePath: string;
}
}
}
declare module L {
export interface IconOptions {
/**
* (required) The URL to the icon image (absolute or relative to your script
* path).
*/
iconUrl?: string;
/**
* The URL to a retina sized version of the icon image (absolute or relative to
* your script path). Used for Retina screen devices.
*/
iconRetinaUrl?: string;
/**
* Size of the icon image in pixels.
*/
iconSize?: Point;
/**
* The coordinates of the "tip" of the icon (relative to its top left corner).
* The icon will be aligned so that this point is at the marker's geographical
* location. Centered by default if size is specified, also can be set in CSS
* with negative margins.
*/
iconAnchor?: Point;
/**
* The URL to the icon shadow image. If not specified, no shadow image will be
* created.
*/
shadowUrl?: string;
/**
* The URL to the retina sized version of the icon shadow image. If not specified,
* no shadow image will be created. Used for Retina screen devices.
*/
shadowRetinaUrl?: string;
/**
* Size of the shadow image in pixels.
*/
shadowSize?: Point;
/**
* The coordinates of the "tip" of the shadow (relative to its top left corner)
* (the same as iconAnchor if not specified).
*/
shadowAnchor?: Point;
/**
* The coordinates of the point from which popups will "open", relative to the
* icon anchor.
*/
popupAnchor?: Point;
/**
* A custom class name to assign to both icon and shadow images. Empty by default.
*/
className?: string;
}
}
declare module L {
export interface IControl {
/**
* Should contain code that creates all the neccessary DOM elements for the
* control, adds listeners on relevant map events, and returns the element
* containing the control. Called on map.addControl(control) or control.addTo(map).
*/
onAdd(map: Map): HTMLElement;
/**
* Optional, should contain all clean up code (e.g. removes control's event
* listeners). Called on map.removeControl(control) or control.removeFrom(map).
* The control's DOM container is removed automatically.
*/
onRemove(map: Map): void;
}
}
declare module L {
export interface ICRS {
/**
* Projection that this CRS uses.
*/
projection: IProjection;
/**
* Transformation that this CRS uses to turn projected coordinates into screen
* coordinates for a particular tile service.
*/
transformation: Transformation;
/**
* Standard code name of the CRS passed into WMS services (e.g. 'EPSG:3857').
*/
code: string;
/**
* Projects geographical coordinates on a given zoom into pixel coordinates.
*/
latLngToPoint(latlng: LatLng, zoom: number): Point;
/**
* The inverse of latLngToPoint. Projects pixel coordinates on a given zoom
* into geographical coordinates.
*/
pointToLatLng(point: Point, zoom: number): LatLng;
/**
* Projects geographical coordinates into coordinates in units accepted
* for this CRS (e.g. meters for EPSG:3857, for passing it to WMS services).
*/
project(latlng: LatLng): Point;
/**
* Returns the scale used when transforming projected coordinates into pixel
* coordinates for a particular zoom. For example, it returns 256 * 2^zoom for
* Mercator-based CRS.
*/
scale(zoom: number): number;
}
}
declare module L {
export interface IEventPowered<T> {
/**
* Adds a listener function (fn) to a particular event type of the object. You
* can optionally specify the context of the listener (object the this keyword
* will point to). You can also pass several space-separated types (e.g. 'click
* dblclick').
*/
addEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): T;
/**
* The same as above except the listener will only get fired once and then removed.
*/
addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): T;
/**
* Adds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}
*/
addEventListener(eventMap: any, context?: any): T;
/**
* Removes a previously added listener function. If no function is specified,
* it will remove all the listeners of that particular event from the object.
*/
removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): T;
/**
* Removes a set of type/listener pairs.
*/
removeEventListener(eventMap?: any, context?: any): T;
/**
* Returns true if a particular event type has some listeners attached to it.
*/
hasEventListeners(type: string): boolean;
/**
* Fires an event of the specified type. You can optionally provide an data object
* — the first argument of the listener function will contain its properties.
*/
fireEvent(type: string, data?: any): T;
/**
* Removes all listeners to all events on the object.
*/
clearAllEventListeners(): T;
/**
* Alias to addEventListener.
*/
on(type: string, fn: (e: LeafletEvent) => void, context?: any): T;
/**
* Alias to addEventListener.
*/
on(eventMap: any, context?: any): T;
/**
* Alias to addOneTimeEventListener.
*/
once(type: string, fn: (e: LeafletEvent) => void, context?: any): T;
/**
* Alias to removeEventListener.
*/
off(type: string, fn?: (e: LeafletEvent) => void, context?: any): T;
/**
* Alias to removeEventListener.
*/
off(eventMap?: any, context?: any): T;
/**
* Alias to fireEvent.
*/
fire(type: string, data?: any): T;
}
}
declare module L {
export interface IHandler {
/**
* Enables the handler.
*/
enable(): void;
/**
* Disables the handler.
*/
disable(): void;
/**
* Returns true if the handler is enabled.
*/
enabled(): boolean;
}
}
declare module L {
export interface ILayer {
/**
* Should contain code that creates DOM elements for the overlay, adds them
* to map panes where they should belong and puts listeners on relevant map events.
* Called on map.addLayer(layer).
*/
onAdd(map: Map): void;
/**
* Should contain all clean up code that removes the overlay's elements from
* the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).
*/
onRemove(map: Map): void;
}
}
declare module L {
/**
* Instantiates an image overlay object given the URL of the image and the geographical
* bounds it is tied to.
*/
function imageOverlay(imageUrl: string, bounds: LatLngBounds, options?: ImageOverlayOptions): ImageOverlay;
export class ImageOverlay extends Class implements ILayer {
/**
* Instantiates an image overlay object given the URL of the image and the geographical
* bounds it is tied to.
*/
constructor(imageUrl: string, bounds: LatLngBounds, options?: ImageOverlayOptions);
/**
* Adds the overlay to the map.
*/
addTo(map: Map): ImageOverlay;
/**
* Sets the opacity of the overlay.
*/
setOpacity(opacity: number): ImageOverlay;
/**
* Brings the layer to the top of all overlays.
*/
bringToFront(): ImageOverlay;
/**
* Brings the layer to the bottom of all overlays.
*/
bringToBack(): ImageOverlay;
////////////
////////////
/**
* Should contain code that creates DOM elements for the overlay, adds them
* to map panes where they should belong and puts listeners on relevant map events.
* Called on map.addLayer(layer).
*/
onAdd(map: Map): void;
/**
* Should contain all clean up code that removes the overlay's elements from
* the DOM and removes listeners previously added in onAdd. Called on map.removeLayer(layer).
*/
onRemove(map: Map): void;
}
}
declare module L {
export interface ImageOverlayOptions {
/**
* The opacity of the image overlay.
*/
opacity?: number;
}
}
declare module L {
export interface IProjection {
/**
* Projects geographical coordinates into a 2D point.
*/
project(latlng: LatLng): Point;
/**
* The inverse of project. Projects a 2D point into geographical location.
*/
unproject(point: Point): LatLng;
}
}
declare module L {
/**
* A constant that represents the Leaflet version in use.
*/
export var version: string;
/**
* This method restores the L global variale to the original value it had
* before Leaflet inclusion, and returns the real Leaflet namespace.
*/
export function noConflict(): typeof L;
}
declare module L {
/**
* Creates an object representing a geographical point with the given latitude
* and longitude.
*/
function latLng(latitude: number, longitude: number): LatLng;
/**
* Creates an object representing a geographical point with the given latitude
* and longitude.
*/
function latLng(coords: number[]): LatLng;
export class LatLng {
/**
* Creates an object representing a geographical point with the given latitude
* and longitude.
*/
constructor(latitude: number, longitude: number);
/**
* Creates an object representing a geographical point with the given latitude
* and longitude.
*/
constructor(coords: number[]);
/**
* Returns the distance (in meters) to the given LatLng calculated using the
* Haversine formula. See description on wikipedia
*/
distanceTo(otherLatlng: LatLng): number;
/**
* Returns true if the given LatLng point is at the same position (within a small
* margin of error).
*/
equals(otherLatlng: LatLng): boolean;
/**
* Returns a string representation of the point (for debugging purposes).
*/
toString(): string;
/**
* Returns a new LatLng object with the longitude wrapped around left and right
* boundaries (-180 to 180 by default).
*/
wrap(left: number, right: number): LatLng;
/**
* Latitude in degrees.
*/
lat: number;
/**
* Longitude in degrees.
*/
lng: number;
/**
* A multiplier for converting degrees into radians.
*
* Value: Math.PI / 180.
*/
static DEG_TO_RAD: number;
/**
* A multiplier for converting radians into degrees.
*
* Value: 180 / Math.PI.
*/
static RAD_TO_DEG: number;
/**
* Max margin of error for the equality check.
*
* Value: 1.0E-9.
*/
static MAX_MARGIN: number;
}
}
declare module L {
/**
* Creates a LatLngBounds object by defining south-west and north-east corners
* of the rectangle.
*/
function latLngBounds(southWest: LatLng, northEast: LatLng): LatLngBounds;
/**
* Creates a LatLngBounds object defined by the geographical points it contains.
* Very useful for zooming the map to fit a particular set of locations with fitBounds.
*/
function latLngBounds(latlngs: LatLng[]): LatLngBounds;
export class LatLngBounds {
/**
* Creates a LatLngBounds object by defining south-west and north-east corners
* of the rectangle.
*/
constructor(southWest: LatLng, northEast: LatLng);
/**
* Creates a LatLngBounds object defined by the geographical points it contains.
* Very useful for zooming the map to fit a particular set of locations with fitBounds.
*/
constructor(latlngs: LatLng[]);
/**
* Extends the bounds to contain the given point.
*/
extend(latlng: LatLng): LatLngBounds;
/**
* Extends the bounds to contain the given bounds.
*/
extend(latlng: LatLngBounds): LatLngBounds;
/**
* Returns the south-west point of the bounds.
*/
getSouthWest(): LatLng;
/**
* Returns the north-east point of the bounds.
*/
getNorthEast(): LatLng;
/**
* Returns the north-west point of the bounds.
*/
getNorthWest(): LatLng;
/**
* Returns the south-east point of the bounds.
*/
getSouthEast(): LatLng;
/**
* Returns the center point of the bounds.
*/
getCenter(): LatLng;
/**
* Returns true if the rectangle contains the given one.
*/
contains(otherBounds: LatLngBounds): boolean;
/**
* Returns true if the rectangle contains the given point.
*/
contains(latlng: LatLng): boolean;
/**
* Returns true if the rectangle intersects the given bounds.
*/
intersects(otherBounds: LatLngBounds): boolean;
/**
* Returns true if the rectangle is equivalent (within a small margin of error)
* to the given bounds.
*/
equals(otherBounds: LatLngBounds): boolean;
/**
* Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat'
* format. Useful for sending requests to web services that return geo data.
*/
toBBoxString(): string;
/**
* Returns bigger bounds created by extending the current bounds by a given
* percentage in each direction.
*/
pad(bufferRatio: number): LatLngBounds;
/**
* Returns true if the bounds are properly initialized.
*/
isValid(): boolean;
}
}
declare module L {
/**
* Create a layer group, optionally given an initial set of layers.
*/
function layerGroup(layers?: ILayer[]): LayerGroup;
export class LayerGroup extends Class implements ILayer {
/**
* Create a layer group, optionally given an initial set of layers.
*/
constructor(layers?: ILayer[]);
/**
* Adds the group of layers to the map.
*/
addTo(map: Map): LayerGroup;
/**
* Adds a given layer to the group.
*/
addLayer(layer: ILayer): LayerGroup;
/**
* Removes a given layer from the group.
*/
removeLayer(layer: ILayer): LayerGroup;
/**
* Removes a given layer of the given id from the group.
*/
removeLayer(id: string): LayerGroup;
/**
* Returns true if the given layer is currently added to the group.
*/
hasLayer(layer: ILayer): boolean;
/**
* Returns the layer with the given id.
*/
getLayer(id: string): ILayer;
/**
* Returns an array of all the layers added to the group.
*/
getLayers(): ILayer[];
/**
* Removes all the layers from the group.
*/
clearLayers(): LayerGroup;
/**
* Iterates over the layers of the group, optionally specifying context of
* the iterator function.
*/
eachLayer(fn: (layer: ILayer) => void, context?: any): LayerGroup;
/**
* Returns a GeoJSON representation of the