UNPKG

declarations

Version:

[![npm version](https://badge.fury.io/js/declarations.svg)](https://www.npmjs.com/package/declarations)

1,626 lines (1,321 loc) 133 kB
// Type definitions for Leaflet.js 1.0.0 // Project: https://github.com/Leaflet/Leaflet // Definitions by: Vladimir Zotov <https://github.com/rgripper> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// <reference path='../geojson/geojson.d.ts' /> declare namespace L { type LatLngExpression = LatLng | number[] | ({ lat: number; lng: number }) type LatLngBoundsExpression = LatLngBounds | LatLngExpression[]; type PositionString = 'topleft' | 'topright' | 'bottomleft' | 'bottomright'; } declare namespace L { export interface AttributionOptions { /** * The position of the control (one of the map corners). See control positions. * Default value: 'bottomright'. */ position?: PositionString; /** * The HTML text shown before the attributions. Pass false to disable. * Default value: 'Powered by Leaflet'. */ prefix?: string; } } declare namespace 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 interface BoundsStatic { /** * Creates a Bounds object from two coordinates (usually top-left and bottom-right * corners). */ new(topLeft: Point, bottomRight: Point): Bounds; /** * Creates a Bounds object defined by the points it contains. */ new(points: Point[]): Bounds; } export var Bounds: BoundsStatic; export interface Bounds { /** * 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 namespace L { namespace Browser { /** * true for all Internet Explorer versions. */ export var ie: boolean; /** * true for Internet Explorer 6. */ export var ie6: boolean; /** * true for Internet Explorer 6. */ export var ie7: boolean; /** * true for webkit-based browsers like Chrome and Safari (including mobile * versions). */ export var webkit: boolean; /** * true for webkit-based browsers that support CSS 3D transformations. */ export var webkit3d: boolean; /** * true for Android mobile browser. */ export var android: boolean; /** * true for old Android stock browsers (2 and 3). */ export var android23: boolean; /** * true for modern mobile browsers (including iOS Safari and different Android * browsers). */ export var mobile: boolean; /** * true for mobile webkit-based browsers. */ export var mobileWebkit: boolean; /** * true for mobile Opera. */ export var mobileOpera: boolean; /** * true for all browsers on touch devices. */ export var touch: boolean; /** * true for browsers with Microsoft touch model (e.g. IE10). */ export var msTouch: boolean; /** * true for devices with Retina screens. */ export var retina: boolean; } } declare namespace L { /** * Instantiates a circle object given a geographical point, a radius in meters * and optionally an options object. */ function circle(latlng: LatLngExpression, radius: number, options?: PathOptions): Circle; export interface CircleStatic extends ClassStatic { /** * Instantiates a circle object given a geographical point, a radius in meters * and optionally an options object. */ new(latlng: LatLngExpression, radius: number, options?: PathOptions): Circle; } export var Circle: CircleStatic; export interface Circle extends Path { /** * 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: LatLngExpression): 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(): GeoJSON.Feature<GeoJSON.Point>; } } declare namespace 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: LatLngExpression, options?: PathOptions): CircleMarker; export interface CircleMarkerStatic extends ClassStatic { /** * 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. */ new(latlng: LatLngExpression, options?: PathOptions): CircleMarker; } export var CircleMarker: CircleMarkerStatic; export interface CircleMarker extends Circle { /** * Sets the position of a circle marker to a new location. */ setLatLng(latlng: LatLngExpression): CircleMarker; /** * Sets the radius of a circle marker. Units are in pixels. */ setRadius(radius: number): CircleMarker; } } declare namespace L { export interface ClassExtendOptions { /** * Your class's constructor function, meaning that it gets called when you do 'new MyClass(...)'. */ initialize?: Function; /** * 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; [prop: string]: any; } export interface ClassStatic { /** * You use L.Class.extend to define new classes, but you can use the * same method on any class to inherit from it. */ extend(options: ClassExtendOptions): any; extend<Options, NewClass>(options: ClassExtendOptions): { new(options?: Options): NewClass }; /** * You can also use the following shortcut when you just need to make * one additional method call. */ addInitHook(methodName: string, ...args: any[]): void; } /** * L.Class powers the OOP facilities of Leaflet and is used to create * almost all of the Leaflet classes documented. */ namespace Class { /** * You use L.Class.extend to define new classes, but you can use the * same method on any class to inherit from it. */ function extend(options: ClassExtendOptions): any; } } declare namespace L { export interface ControlStatic extends ClassStatic { /** * Creates a control with the given options. */ new(options?: ControlOptions): Control; Zoom: Control.ZoomStatic; Attribution: Control.AttributionStatic; Layers: Control.LayersStatic; Scale: Control.ScaleStatic; } export var Control: ControlStatic; export interface Control extends IControl { /** * Sets the position of the control. See control positions. */ setPosition(position: PositionString): Control; /** * Returns the current position of the control. */ getPosition(): PositionString; /** * 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; } namespace Control { export interface ZoomStatic extends ClassStatic { /** * Creates a zoom control. */ new (options?: ZoomOptions): Zoom; } export interface Zoom extends L.Control { } export interface ZoomOptions { /** * The position of the control (one of the map corners). * Can be 'topleft', 'topright', 'bottomleft', or 'bottomright'. * * Default value: 'topright'. */ position?: PositionString; /** * The text set on the zoom in button. * * Default value: '+' */ zoomInText?: string; /** * The text set on the zoom out button. * * Default value: '-' */ zoomOutText?: string; /** * The title set on the zoom in button. * * Default value: 'Zoom in' */ zoomInTitle?: string; /** * The title set on the zoom out button. * * Default value: 'Zoom out' */ zoomOutTitle?: string; } export interface AttributionStatic extends ClassStatic { /** * Creates an attribution control. */ new(options?: AttributionOptions): Attribution; } export interface Attribution extends L.Control { /** * Sets the text before the attributions. */ setPrefix(prefix: string): Attribution; /** * Adds an attribution text (e.g. 'Vector data &copy; CloudMade'). */ addAttribution(text: string): Attribution; /** * Removes an attribution text. */ removeAttribution(text: string): Attribution; } export interface LayersStatic extends ClassStatic { /** * Creates an attribution control with the given layers. Base layers will be * switched with radio buttons, while overlays will be switched with checkboxes. */ new(baseLayers?: any, overlays?: any, options?: LayersOptions): Layers; } export interface Layers extends L.Control, IEventPowered<Layers> { /** * 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 interface ScaleStatic extends ClassStatic { /** * Creates an scale control with the given options. */ new(options?: ScaleOptions): Scale; } export interface Scale extends L.Control { } } export interface control { /** * Creates a control with the given options. */ (options?: ControlOptions): Control; } export namespace control { /** * Creates a zoom control. */ export function zoom(options?: Control.ZoomOptions): L.Control.Zoom; /** * Creates an attribution control. */ export function 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. */ export function layers(baseLayers?: any, overlays?: any, options?: LayersOptions): L.Control.Layers; /** * Creates an scale control with the given options. */ export function scale(options?: ScaleOptions): L.Control.Scale; } } declare namespace L { export interface ControlOptions { /** * The initial position of the control (one of the map corners). See control * positions. * Default value: 'topright'. */ position?: PositionString; } } declare namespace L { namespace 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. */ export var EPSG3857: ICRS; /** * A common CRS among GIS enthusiasts. Uses simple Equirectangular projection. */ export var EPSG4326: ICRS; /** * Rarely used by some commercial tile providers. Uses Elliptical Mercator * projection. */ export var 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). */ export var Simple: ICRS; } } declare namespace L { /** * Creates a div icon instance with the given options. */ function divIcon(options: DivIconOptions): DivIcon; export interface DivIconStatic extends ClassStatic { /** * Creates a div icon instance with the given options. */ new(options: DivIconOptions): DivIcon; } export var DivIcon: DivIconStatic; export interface DivIcon extends Icon { } } declare namespace L { export interface DivIconOptions { /** * Size of the icon in pixels. Can be also set through CSS. */ iconSize?: Point|[number, number]; /** * 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|[number, number]; /** * 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; /** * The coordinates of the point from which popups will "open", relative to the * icon anchor. */ popupAnchor?: Point|[number, number]; } } declare namespace L { export interface 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. */ addListener(el: HTMLElement, type: string, fn: (e: Event) => void, context?: any): DomEvent; on(el: HTMLElement, type: string, fn: (e: Event) => void, context?: any): DomEvent; /** * Removes an event listener from the element. */ removeListener(el: HTMLElement, type: string, fn: (e: Event) => void, context?: any): DomEvent; off(el: HTMLElement, type: string, fn: (e: Event) => void, context?: any): 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); * }); */ 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. */ preventDefault(e: Event): DomEvent; /** * Does stopPropagation and preventDefault at the same time. */ stop(e: Event): DomEvent; /** * Adds stopPropagation to the element's 'click', 'doubleclick', 'mousedown' * and 'touchstart' events. */ disableClickPropagation(el: HTMLElement): DomEvent; /** * Gets normalized mouse position from a DOM event relative to the container * or to the whole page if not specified. */ getMousePosition(e: Event, container?: HTMLElement): Point; /** * Gets normalized wheel delta from a mousewheel DOM event. */ getWheelDelta(e: Event): number; } export var DomEvent: DomEvent; } declare namespace L { namespace DomUtil { /** * Returns an element with the given id if a string was passed, or just returns * the element if it was passed directly. */ export function get(id: string): HTMLElement; /** * Returns the value for a certain style attribute on an element, including * computed values or values set through CSS. */ export function getStyle(el: HTMLElement, style: string): string; /** * Returns the offset to the viewport for the requested element. */ export function getViewportOffset(el: HTMLElement): Point; /** * Creates an element with tagName, sets the className, and optionally appends * it to container element. */ export function create(tagName: string, className: string, container?: HTMLElement): HTMLElement; /** * Makes sure text cannot be selected, for example during dragging. */ export function disableTextSelection(): void; /** * Makes text selection possible again. */ export function enableTextSelection(): void; /** * Returns true if the element class attribute contains name. */ export function hasClass(el: HTMLElement, name: string): boolean; /** * Adds name to the element's class attribute. */ export function addClass(el: HTMLElement, name: string): void; /** * Removes name from the element's class attribute. */ export function removeClass(el: HTMLElement, name: string): void; /** * Set the opacity of an element (including old IE support). Value must be from * 0 to 1. */ export function 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. */ export function 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. */ export function getTranslateString(point: Point): string; /** * Returns a CSS transform string to scale an element (with the given scale origin). */ export function 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. */ export function setPosition(el: HTMLElement, point: Point, disable3D?: boolean): void; /** * Returns the coordinates of an element previously positioned with setPosition. */ export function getPosition(el: HTMLElement): Point; /** * Vendor-prefixed transition style name (e.g. 'webkitTransition' for WebKit). */ export var TRANSITION: string; /** * Vendor-prefixed transform style name. */ export var TRANSFORM: string; } } declare namespace L { export interface DraggableStatic extends ClassStatic { /** * Creates a Draggable object for moving the given element when you start dragging * the dragHandle element (equals the element itself by default). */ new(element: HTMLElement, dragHandle?: HTMLElement): Draggable; } export var Draggable: DraggableStatic; export interface Draggable extends IEventPowered<Draggable> { /** * 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 namespace L { /** * Create a layer group, optionally given an initial set of layers. */ function featureGroup<T extends ILayer>(layers?: T[]): FeatureGroup<T>; export interface FeatureGroupStatic extends ClassStatic { /** * Create a layer group, optionally given an initial set of layers. */ new<T extends ILayer>(layers?: T[]): FeatureGroup<T>; } export var FeatureGroup: FeatureGroupStatic; export interface FeatureGroup<T extends ILayer> extends LayerGroup<T>, ILayer, IEventPowered<FeatureGroup<T>> { /** * 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<T>; /** * 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<T>; /** * Brings the layer group to the top of all other layers. */ bringToFront(): FeatureGroup<T>; /** * Brings the layer group to the bottom of all other layers. */ bringToBack(): FeatureGroup<T>; //////////// //////////// /** * 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<T>; addOneTimeEventListener(type: string, fn: (e: LeafletEvent) => void, context?: any): FeatureGroup<T>; removeEventListener(type: string, fn?: (e: LeafletEvent) => void, context?: any): FeatureGroup<T>; hasEventListeners(type: string): boolean; fireEvent(type: string, data?: any): FeatureGroup<T>; on(type: string, fn: (e: LeafletEvent) => void, context?: any): FeatureGroup<T>; once(type: string, fn: (e: LeafletEvent) => void, context?: any): FeatureGroup<T>; off(type: string, fn?: (e: LeafletEvent) => void, context?: any): FeatureGroup<T>; fire(type: string, data?: any): FeatureGroup<T>; addEventListener(eventMap: any, context?: any): FeatureGroup<T>; removeEventListener(eventMap?: any, context?: any): FeatureGroup<T>; clearAllEventListeners(): FeatureGroup<T>; on(eventMap: any, context?: any): FeatureGroup<T>; off(eventMap?: any, context?: any): FeatureGroup<T>; } } declare namespace 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 interface GeoJSONStatic extends ClassStatic { /** * 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. */ new(geojson?: any, options?: GeoJSONOptions): GeoJSON; /** * Creates a layer from a given GeoJSON feature. */ 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). */ 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). */ coordsToLatLngs(coords: any[], levelsDeep?: number, reverse?: boolean): any[]; } export var GeoJSON: GeoJSONStatic; export interface GeoJSON extends FeatureGroup<ILayer> { /** * 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; /** * Changes styles of GeoJSON vector layers with the given style options. */ setStyle(style: PathOptions): 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; } } declare namespace 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 namespace L { /** * Creates an icon instance with the given options. */ function icon(options: IconOptions): Icon; export interface IconStatic extends ClassStatic { /** * Creates an icon instance with the given options. */ new(options: IconOptions): Icon; Default: { /** * Creates a default icon instance with the given options. */ new(options?: IconOptions): Icon.Default; imagePath: string; }; } export var Icon: IconStatic; export interface Icon { } namespace Icon { /** * L.Icon.Default extends L.Icon and is the blue icon Leaflet uses * for markers by default. */ export interface Default extends Icon { } } } declare namespace 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|[number, number]; /** * 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|[number, number]; /** * 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|[number, number]; /** * The coordinates of the "tip" of the shadow (relative to its top left corner) * (the same as iconAnchor if not specified). */ shadowAnchor?: Point|[number, number]; /** * The coordinates of the point from which popups will "open", relative to the * icon anchor. */ popupAnchor?: Point|[number, number]; /** * A custom class name to assign to both icon and shadow images. Empty by default. */ className?: string; } } declare namespace 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 namespace 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; /** * Returns the size of the world in pixels for a particular zoom. */ getSize(zoom: number): Point; } } declare namespace 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 namespace L { export interface IHandler { /** * Enables the handler. */ enable(): void; /** * Disables the handler. */ disable(): void; /** * Returns true if the handler is enabled. */ enabled(): boolean; } export interface Handler { initialize(map: Map): void; } } declare namespace 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 namespace L { namespace Mixin { export interface LeafletMixinEvents extends IEventPowered<LeafletMixinEvents> { } export var Events: LeafletMixinEvents; } } declare namespace 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 interface ImageOverlayStatic extends ClassStatic { /** * Instantiates an image overlay object given the URL of the image and the geographical * bounds it is tied to. */ new(imageUrl: string, bounds: LatLngBounds, options?: ImageOverlayOptions): ImageOverlay; } export var ImageOverlay: ImageOverlayStatic; export interface ImageOverlay extends ILayer { /** * Adds the overlay to the map. */ addTo(map: Map): ImageOverlay; /** * Sets the opacity of the overlay. */ setOpacity(opacity: number): ImageOverlay; /** * Changes the URL of the image. */ setUrl(imageUrl: string): 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 namespace L { export interface ImageOverlayOptions { /** * The opacity of the image overlay. */ opacity?: number; } } declare namespace 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 namespace 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 namespace 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: LatLngExpression): LatLng; export interface LatLngStatic { /** * Creates an object representing a geographical point with the given latitude * and longitude. */ new(latitude: number, longitude: number): LatLng; /** * Creates an object representing a geographical point with the given latitude * and longitude. */ new(coords: LatLngExpression): LatLng; /** * A multiplier for converting degrees into radians. * * Value: Math.PI / 180. */ DEG_TO_RAD: number; /** * A multiplier for converting radians into degrees. * * Value: 180 / Math.PI. */ RAD_TO_DEG: number; /** * Max margin of error for the equality check. * * Value: 1.0E-9. */ MAX_MARGIN: number; } export var LatLng: LatLngStatic; export interface LatLng { /** * Returns the distance (in meters) to the given LatLng calculated using the * Haversine formula. See description on wikipedia */ distanceTo(otherLatlng: LatLngExpression): number; /** * Returns true if the given LatLng point is at the same position (within a small * margin of error). */ equals(otherLatlng: LatLngExpression): 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; } } declare namespace L { /** * Creates a LatLngBounds object by defining south-west and north-east corners * of the rectangle. */ function latLngBounds(southWest: LatLngExpression, northEast: LatLngExpression): 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: LatLngBoundsExpression): LatLngBounds; export interface LatLngBoundsStatic { /** * Creates a LatLngBounds object by defining south-west and north-east corners * of the rectangle. */ new(southWest: LatLngExpression, northEast: LatLngExpression): 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. */ new(latlngs: LatLngBoundsExpression): LatLngBounds; } export var LatLngBounds: LatLngBoundsStatic; export interface LatLngBounds { /** * Extends the bounds to contain the given point. */ extend(latlng: LatLngExpression): LatLngBounds; /** * Extends the bounds to contain the given bounds. */ extend(latlng: LatLngBoundsExpression): 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 west longitude in degrees of the bounds. */ getWest(): number; /** * Returns the east longitude in degrees of the bounds. */ getEast(): number; /** * Returns the north latitude in degrees of the bounds. */ getNorth(): number; /** * Returns the south latitude in degrees of the bounds. */ getSouth(): number; /** * Returns the center point of the bounds. */ getCenter(): LatLng; /** * Returns true if the rectangle contains the given one. */ contains(otherBounds: LatLngBoundsExpression): boolean; /** * Returns true if the rectangle contains the given point. */ contains(latlng: LatLngExpression): boolean; /** * Returns true if the rectangle intersects the given bounds. */ intersects(otherBounds: LatLngBoundsExpression): boolean; /** * Returns true if the rectangle is