@types/openlayers
Version:
TypeScript definitions for openlayers
1,442 lines (1,334 loc) • 422 kB
TypeScript
export as namespace ol;
export interface GlobalObject {
[key: string]: any;
}
/**
* Error object thrown when an assertion failed. This is an ECMA-262 Error,
* extended with a `code` property.
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error}
* @param code Error code.
*/
export class AssertionError extends Error {
/**
* Error object thrown when an assertion failed. This is an ECMA-262 Error,
* extended with a `code` property.
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error}
* @param code Error code.
*/
constructor(code: number);
/**
* Error code. The meaning of the code can be found on
* {@link http://openlayers.org/en/latest/errors.html} (replace `latest` with
* the version found in the OpenLayers script's header comment if a version
* other than the latest is used).
* @api
*/
code: number;
}
/**
* @classdesc
* An attribution for a layer source.
*
* Example:
*
* source: new ol.source.OSM({
* attributions: [
* new ol.Attribution({
* html: 'All maps © ' +
* '<a href="http://www.opencyclemap.org/">OpenCycleMap</a>'
* }),
* ol.source.OSM.ATTRIBUTION
* ],
* ..
*
* @param options Attribution options.
* @struct
* @api stable
*/
export class Attribution {
/**
* @classdesc
* An attribution for a layer source.
*
* Example:
*
* source: new ol.source.OSM({
* attributions: [
* new ol.Attribution({
* html: 'All maps © ' +
* '<a href="http://www.opencyclemap.org/">OpenCycleMap</a>'
* }),
* ol.source.OSM.ATTRIBUTION
* ],
* ..
*
* @param options Attribution options.
* @struct
* @api stable
*/
constructor(options: olx.AttributionOptions);
/**
* Get the attribution markup.
* @return The attribution HTML.
* @api stable
*/
getHTML(): string;
}
/**
* @classdesc
* An expanded version of standard JS Array, adding convenience methods for
* manipulation. Add and remove changes to the Collection trigger a Collection
* event. Note that this does not cover changes to the objects _within_ the
* Collection; they trigger events on the appropriate object, not on the
* Collection as a whole.
*
* @fires ol.Collection.Event
* @param opt_array Array.
* @template T
* @api stable
*/
export class Collection<T> extends Object {
/**
* @classdesc
* An expanded version of standard JS Array, adding convenience methods for
* manipulation. Add and remove changes to the Collection trigger a Collection
* event. Note that this does not cover changes to the objects _within_ the
* Collection; they trigger events on the appropriate object, not on the
* Collection as a whole.
*
* @fires ol.Collection.Event
* @param opt_array Array.
* @template T
* @api stable
*/
constructor(opt_array?: T[]);
/**
* Remove all elements from the collection.
* @api stable
*/
clear(): void;
/**
* Add elements to the collection. This pushes each item in the provided array
* to the end of the collection.
* @param arr Array.
* @return This collection.
* @api stable
*/
extend(arr: T[]): ol.Collection<T>;
/**
* Iterate over each element, calling the provided callback.
* @param f The function to call
* for every element. This function takes 3 arguments (the element, the
* index and the array). The return value is ignored.
* @param opt_this The object to use as `this` in `f`.
* @template S
* @api stable
*/
forEach(f: (item: T, index: number, array: T[]) => any, opt_this?: any): void;
/**
* Get a reference to the underlying Array object. Warning: if the array
* is mutated, no events will be dispatched by the collection, and the
* collection's "length" property won't be in sync with the actual length
* of the array.
* @return Array.
* @api stable
*/
getArray(): T[];
/**
* Get the element at the provided index.
* @param index Index.
* @return Element.
* @api stable
*/
item(index: number): T;
/**
* Get the length of this collection.
* @return The length of the array.
* @observable
* @api stable
*/
getLength(): number;
/**
* Insert an element at the provided index.
* @param index Index.
* @param elem Element.
* @api stable
*/
insertAt(index: number, elem: T): void;
/**
* Remove the last element of the collection and return it.
* Return `undefined` if the collection is empty.
* @return Element.
* @api stable
*/
pop(): T;
/**
* Insert the provided element at the end of the collection.
* @param elem Element.
* @return Length.
* @api stable
*/
push(elem: T): number;
/**
* Remove the first occurrence of an element from the collection.
* @param elem Element.
* @return The removed element or undefined if none found.
* @api stable
*/
remove(elem: T): T;
/**
* Remove the element at the provided index and return it.
* Return `undefined` if the collection does not contain this index.
* @param index Index.
* @return Value.
* @api stable
*/
removeAt(index: number): T;
/**
* Set the element at the provided index.
* @param index Index.
* @param elem Element.
* @api stable
*/
setAt(index: number, elem: T): void;
}
export namespace Collection {
type EventType = string;
/**
* @classdesc
* Events emitted by {@link ol.Collection} instances are instances of this
* type.
*
* @param type Type.
* @param opt_element Element.
*/
class Event extends events.Event {
/**
* @classdesc
* Events emitted by {@link ol.Collection} instances are instances of this
* type.
*
* @param type Type.
* @param opt_element Element.
*/
constructor(type: EventType, opt_element?: any);
/**
* The element that is added to or removed from the collection.
* @api stable
*/
element: any;
}
}
/**
* Colors can be defined as a {@link ol.Color} array, or as strings in
* `rgb(r,g,b)` or `rgba(r,g,b,a)` format, or in hex `#rrggbb` or `#rgb` format.
* Color names, like 'red', 'blue' or 'green', may also be used with the
* Canvas renderer.
*/
export namespace color {
/**
* Return the color as an array. This function maintains a cache of calculated
* arrays which means the result should not be modified.
* @param color Color.
* @return Color.
* @api
*/
function asArray(color: ol.Color | string): ol.Color;
/**
* Return the color as an rgba string.
* @param color Color.
* @return Rgba string.
* @api
*/
function asString(color: ol.Color | string): string;
}
/**
* An {@link ol.ColorLike} can be a color, gradient or pattern accepted by
* [CanvasRenderingContext2D.fillStyle](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle).
*/
export namespace colorlike {
/**
* @param color Color.
* @return The color as an ol.ColorLike
* @api
*/
function asColorLike(color: ol.Color | ol.ColorLike): ol.ColorLike;
}
export namespace control {
/**
* @classdesc
* Control to show all the attributions associated with the layer sources
* in the map. This control is one of the default controls included in maps.
* By default it will show in the bottom right portion of the map, but this can
* be changed by using a css selector for `.ol-attribution`.
*
* @param opt_options Attribution options.
* @api stable
*/
class Attribution extends Control {
/**
* @classdesc
* Control to show all the attributions associated with the layer sources
* in the map. This control is one of the default controls included in maps.
* By default it will show in the bottom right portion of the map, but this can
* be changed by using a css selector for `.ol-attribution`.
*
* @param opt_options Attribution options.
* @api stable
*/
constructor(opt_options?: olx.control.AttributionOptions);
/**
* Update the attribution element.
* @param mapEvent Map event.
* @api
*/
static render(mapEvent: ol.MapEvent): void;
/**
* Return `true` if the attribution is collapsible, `false` otherwise.
* @return True if the widget is collapsible.
* @api stable
*/
getCollapsible(): boolean;
/**
* Set whether the attribution should be collapsible.
* @param collapsible True if the widget is collapsible.
* @api stable
*/
setCollapsible(collapsible: boolean): void;
/**
* Collapse or expand the attribution according to the passed parameter. Will
* not do anything if the attribution isn't collapsible or if the current
* collapsed state is already the one requested.
* @param collapsed True if the widget is collapsed.
* @api stable
*/
setCollapsed(collapsed: boolean): void;
/**
* Return `true` when the attribution is currently collapsed or `false`
* otherwise.
* @return True if the widget is collapsed.
* @api stable
*/
getCollapsed(): boolean;
}
/**
* @classdesc
* A control is a visible widget with a DOM element in a fixed position on the
* screen. They can involve user input (buttons), or be informational only;
* the position is determined using CSS. By default these are placed in the
* container with CSS class name `ol-overlaycontainer-stopevent`, but can use
* any outside DOM element.
*
* This is the base class for controls. You can use it for simple custom
* controls by creating the element with listeners, creating an instance:
* ```js
* var myControl = new ol.control.Control({element: myElement});
* ```
* and then adding this to the map.
*
* The main advantage of having this as a control rather than a simple separate
* DOM element is that preventing propagation is handled for you. Controls
* will also be `ol.Object`s in a `ol.Collection`, so you can use their
* methods.
*
* You can also extend this base for your own control class. See
* examples/custom-controls for an example of how to do this.
*
* @param options Control options.
* @api stable
*/
class Control extends Object {
/**
* @classdesc
* A control is a visible widget with a DOM element in a fixed position on the
* screen. They can involve user input (buttons), or be informational only;
* the position is determined using CSS. By default these are placed in the
* container with CSS class name `ol-overlaycontainer-stopevent`, but can use
* any outside DOM element.
*
* This is the base class for controls. You can use it for simple custom
* controls by creating the element with listeners, creating an instance:
* ```js
* var myControl = new ol.control.Control({element: myElement});
* ```
* and then adding this to the map.
*
* The main advantage of having this as a control rather than a simple separate
* DOM element is that preventing propagation is handled for you. Controls
* will also be `ol.Object`s in a `ol.Collection`, so you can use their
* methods.
*
* You can also extend this base for your own control class. See
* examples/custom-controls for an example of how to do this.
*
* @param options Control options.
* @api stable
*/
constructor(options: olx.control.ControlOptions);
/**
* Get the map associated with this control.
* @return Map.
* @api stable
*/
getMap(): ol.Map;
/**
* Remove the control from its current map and attach it to the new map.
* Subclasses may set up event handlers to get notified about changes to
* the map here.
* @param map Map.
* @api stable
*/
setMap(map: ol.Map): void;
/**
* This function is used to set a target element for the control. It has no
* effect if it is called after the control has been added to the map (i.e.
* after `setMap` is called on the control). If no `target` is set in the
* options passed to the control constructor and if `setTarget` is not called
* then the control is added to the map's overlay container.
* @param target Target.
* @api
*/
setTarget(target: Element | string): void;
}
/**
* @classdesc
* Provides a button that when clicked fills up the full screen with the map.
* The full screen source element is by default the element containing the map viewport unless
* overriden by providing the `source` option. In which case, the dom
* element introduced using this parameter will be displayed in full screen.
*
* When in full screen mode, a close button is shown to exit full screen mode.
* The [Fullscreen API](http://www.w3.org/TR/fullscreen/) is used to
* toggle the map in full screen mode.
*
* @param opt_options Options.
* @api stable
*/
class FullScreen extends Control {
/**
* @classdesc
* Provides a button that when clicked fills up the full screen with the map.
* The full screen source element is by default the element containing the map viewport unless
* overriden by providing the `source` option. In which case, the dom
* element introduced using this parameter will be displayed in full screen.
*
* When in full screen mode, a close button is shown to exit full screen mode.
* The [Fullscreen API](http://www.w3.org/TR/fullscreen/) is used to
* toggle the map in full screen mode.
*
* @param opt_options Options.
* @api stable
*/
constructor(opt_options?: olx.control.FullScreenOptions);
}
/**
* Set of controls included in maps by default. Unless configured otherwise,
* this returns a collection containing an instance of each of the following
* controls:
* * {@link ol.control.Zoom}
* * {@link ol.control.Rotate}
* * {@link ol.control.Attribution}
*
* @param opt_options Defaults options.
* @return Controls.
* @api stable
*/
function defaults(opt_options?: olx.control.DefaultsOptions): ol.Collection<Control>;
/**
* @classdesc
* A control to show the 2D coordinates of the mouse cursor. By default, these
* are in the view projection, but can be in any supported projection.
* By default the control is shown in the top right corner of the map, but this
* can be changed by using the css selector `.ol-mouse-position`.
*
* @param opt_options Mouse position
* options.
* @api stable
*/
class MousePosition extends Control {
/**
* @classdesc
* A control to show the 2D coordinates of the mouse cursor. By default, these
* are in the view projection, but can be in any supported projection.
* By default the control is shown in the top right corner of the map, but this
* can be changed by using the css selector `.ol-mouse-position`.
*
* @param opt_options Mouse position
* options.
* @api stable
*/
constructor(opt_options?: olx.control.MousePositionOptions);
/**
* Update the mouseposition element.
* @param mapEvent Map event.
* @api
*/
static render(mapEvent: ol.MapEvent): void;
/**
* Return the coordinate format type used to render the current position or
* undefined.
* @return The format to render the current
* position in.
* @observable
* @api stable
*/
getCoordinateFormat(): ol.CoordinateFormatType;
/**
* Return the projection that is used to report the mouse position.
* @return The projection to report mouse
* position in.
* @observable
* @api stable
*/
getProjection(): ol.proj.Projection;
/**
* Set the coordinate format type used to render the current position.
* @param format The format to render the current
* position in.
* @observable
* @api stable
*/
setCoordinateFormat(format: ol.CoordinateFormatType): void;
/**
* Set the projection that is used to report the mouse position.
* @param projection The projection to report mouse
* position in.
* @observable
* @api stable
*/
setProjection(projection: ol.proj.Projection): void;
}
/**
* Create a new control with a map acting as an overview map for an other
* defined map.
* @param opt_options OverviewMap options.
* @api
*/
class OverviewMap extends Control {
/**
* Create a new control with a map acting as an overview map for an other
* defined map.
* @param opt_options OverviewMap options.
* @api
*/
constructor(opt_options?: olx.control.OverviewMapOptions);
/**
* Update the overview map element.
* @param mapEvent Map event.
* @api
*/
static render(mapEvent: ol.MapEvent): void;
/**
* Return `true` if the overview map is collapsible, `false` otherwise.
* @return True if the widget is collapsible.
* @api stable
*/
getCollapsible(): boolean;
/**
* Set whether the overview map should be collapsible.
* @param collapsible True if the widget is collapsible.
* @api stable
*/
setCollapsible(collapsible: boolean): void;
/**
* Collapse or expand the overview map according to the passed parameter. Will
* not do anything if the overview map isn't collapsible or if the current
* collapsed state is already the one requested.
* @param collapsed True if the widget is collapsed.
* @api stable
*/
setCollapsed(collapsed: boolean): void;
/**
* Determine if the overview map is collapsed.
* @return The overview map is collapsed.
* @api stable
*/
getCollapsed(): boolean;
/**
* Return the overview map.
* @return Overview map.
* @api
*/
getOverviewMap(): ol.Map;
}
/**
* @classdesc
* A button control to reset rotation to 0.
* To style this control use css selector `.ol-rotate`. A `.ol-hidden` css
* selector is added to the button when the rotation is 0.
*
* @param opt_options Rotate options.
* @api stable
*/
class Rotate extends Control {
/**
* @classdesc
* A button control to reset rotation to 0.
* To style this control use css selector `.ol-rotate`. A `.ol-hidden` css
* selector is added to the button when the rotation is 0.
*
* @param opt_options Rotate options.
* @api stable
*/
constructor(opt_options?: olx.control.RotateOptions);
/**
* Update the rotate control element.
* @param mapEvent Map event.
* @api
*/
static render(mapEvent: ol.MapEvent): void;
}
/**
* @classdesc
* A control displaying rough y-axis distances, calculated for the center of the
* viewport. For conformal projections (e.g. EPSG:3857, the default view
* projection in OpenLayers), the scale is valid for all directions.
* No scale line will be shown when the y-axis distance of a pixel at the
* viewport center cannot be calculated in the view projection.
* By default the scale line will show in the bottom left portion of the map,
* but this can be changed by using the css selector `.ol-scale-line`.
*
* @param opt_options Scale line options.
* @api stable
*/
class ScaleLine extends Control {
/**
* @classdesc
* A control displaying rough y-axis distances, calculated for the center of the
* viewport. For conformal projections (e.g. EPSG:3857, the default view
* projection in OpenLayers), the scale is valid for all directions.
* No scale line will be shown when the y-axis distance of a pixel at the
* viewport center cannot be calculated in the view projection.
* By default the scale line will show in the bottom left portion of the map,
* but this can be changed by using the css selector `.ol-scale-line`.
*
* @param opt_options Scale line options.
* @api stable
*/
constructor(opt_options?: olx.control.ScaleLineOptions);
/**
* Return the units to use in the scale line.
* @return The units to use in the scale
* line.
* @observable
* @api stable
*/
getUnits(): ScaleLine.Units;
/**
* Update the scale line element.
* @param mapEvent Map event.
* @api
*/
static render(mapEvent: ol.MapEvent): void;
/**
* Set the units to use in the scale line.
* @param units The units to use in the scale line.
* @observable
* @api stable
*/
setUnits(units: ScaleLine.Units): void;
}
namespace ScaleLine {
/**
* @api
*/
type Property = string;
/**
* Units for the scale line. Supported values are `'degrees'`, `'imperial'`,
* `'nautical'`, `'metric'`, `'us'`.
*/
type Units = "degrees" | "imperial" | "nautical" | "metric" | "us";
}
/**
* @classdesc
* A control with 2 buttons, one for zoom in and one for zoom out.
* This control is one of the default controls of a map. To style this control
* use css selectors `.ol-zoom-in` and `.ol-zoom-out`.
*
* @param opt_options Zoom options.
* @api stable
*/
class Zoom extends Control {
/**
* @classdesc
* A control with 2 buttons, one for zoom in and one for zoom out.
* This control is one of the default controls of a map. To style this control
* use css selectors `.ol-zoom-in` and `.ol-zoom-out`.
*
* @param opt_options Zoom options.
* @api stable
*/
constructor(opt_options?: olx.control.ZoomOptions);
}
/**
* @classdesc
* A slider type of control for zooming.
*
* Example:
*
* map.addControl(new ol.control.ZoomSlider());
*
* @param opt_options Zoom slider options.
* @api stable
*/
class ZoomSlider extends Control {
/**
* @classdesc
* A slider type of control for zooming.
*
* Example:
*
* map.addControl(new ol.control.ZoomSlider());
*
* @param opt_options Zoom slider options.
* @api stable
*/
constructor(opt_options?: olx.control.ZoomSliderOptions);
/**
* Update the zoomslider element.
* @param mapEvent Map event.
* @api
*/
static render(mapEvent: ol.MapEvent): void;
}
/**
* @classdesc
* A button control which, when pressed, changes the map view to a specific
* extent. To style this control use the css selector `.ol-zoom-extent`.
*
* @param opt_options Options.
* @api stable
*/
class ZoomToExtent extends Control {
/**
* @classdesc
* A button control which, when pressed, changes the map view to a specific
* extent. To style this control use the css selector `.ol-zoom-extent`.
*
* @param opt_options Options.
* @api stable
*/
constructor(opt_options?: olx.control.ZoomToExtentOptions);
}
}
export namespace coordinate {
/**
* Add `delta` to `coordinate`. `coordinate` is modified in place and returned
* by the function.
*
* Example:
*
* var coord = [7.85, 47.983333];
* ol.coordinate.add(coord, [-2, 4]);
* // coord is now [5.85, 51.983333]
*
* @param coordinate Coordinate.
* @param delta Delta.
* @return The input coordinate adjusted by the given delta.
* @api stable
*/
function add(coordinate: ol.Coordinate, delta: ol.Coordinate): ol.Coordinate;
/**
* Returns a {@link ol.CoordinateFormatType} function that can be used to format
* a {ol.Coordinate} to a string.
*
* Example without specifying the fractional digits:
*
* var coord = [7.85, 47.983333];
* var stringifyFunc = ol.coordinate.createStringXY();
* var out = stringifyFunc(coord);
* // out is now '8, 48'
*
* Example with explicitly specifying 2 fractional digits:
*
* var coord = [7.85, 47.983333];
* var stringifyFunc = ol.coordinate.createStringXY(2);
* var out = stringifyFunc(coord);
* // out is now '7.85, 47.98'
*
* @param opt_fractionDigits The number of digits to include
* after the decimal point. Default is `0`.
* @return Coordinate format.
* @api stable
*/
function createStringXY(opt_fractionDigits?: number): ol.CoordinateFormatType;
/**
* Transforms the given {@link ol.Coordinate} to a string using the given string
* template. The strings `{x}` and `{y}` in the template will be replaced with
* the first and second coordinate values respectively.
*
* Example without specifying the fractional digits:
*
* var coord = [7.85, 47.983333];
* var template = 'Coordinate is ({x}|{y}).';
* var out = ol.coordinate.format(coord, template);
* // out is now 'Coordinate is (8|48).'
*
* Example explicitly specifying the fractional digits:
*
* var coord = [7.85, 47.983333];
* var template = 'Coordinate is ({x}|{y}).';
* var out = ol.coordinate.format(coord, template, 2);
* // out is now 'Coordinate is (7.85|47.98).'
*
* @param coordinate Coordinate.
* @param template A template string with `{x}` and `{y}` placeholders
* that will be replaced by first and second coordinate values.
* @param opt_fractionDigits The number of digits to include
* after the decimal point. Default is `0`.
* @return Formatted coordinate.
* @api stable
*/
function format(coordinate: ol.Coordinate, template: string, opt_fractionDigits?: number): string;
/**
* Rotate `coordinate` by `angle`. `coordinate` is modified in place and
* returned by the function.
*
* Example:
*
* var coord = [7.85, 47.983333];
* var rotateRadians = Math.PI / 2; // 90 degrees
* ol.coordinate.rotate(coord, rotateRadians);
* // coord is now [-47.983333, 7.85]
*
* @param coordinate Coordinate.
* @param angle Angle in radian.
* @return Coordinate.
* @api stable
*/
function rotate(coordinate: ol.Coordinate, angle: number): ol.Coordinate;
/**
* Format a geographic coordinate with the hemisphere, degrees, minutes, and
* seconds.
*
* Example without specifying fractional digits:
*
* var coord = [7.85, 47.983333];
* var out = ol.coordinate.toStringHDMS(coord);
* // out is now '47° 58′ 60″ N 7° 50′ 60″ E'
*
* Example explicitly specifying 1 fractional digit:
*
* var coord = [7.85, 47.983333];
* var out = ol.coordinate.toStringHDMS(coord, 1);
* // out is now '47° 58′ 60.0″ N 7° 50′ 60.0″ E'
*
* @param coordinate Coordinate.
* @param opt_fractionDigits The number of digits to include
* after the decimal point. Default is `0`.
* @return Hemisphere, degrees, minutes and seconds.
* @api stable
*/
function toStringHDMS(coordinate?: ol.Coordinate, opt_fractionDigits?: number): string;
/**
* Format a coordinate as a comma delimited string.
*
* Example without specifying fractional digits:
*
* var coord = [7.85, 47.983333];
* var out = ol.coordinate.toStringXY(coord);
* // out is now '8, 48'
*
* Example explicitly specifying 1 fractional digit:
*
* var coord = [7.85, 47.983333];
* var out = ol.coordinate.toStringXY(coord, 1);
* // out is now '7.8, 48.0'
*
* @param coordinate Coordinate.
* @param opt_fractionDigits The number of digits to include
* after the decimal point. Default is `0`.
* @return XY.
* @api stable
*/
function toStringXY(coordinate?: ol.Coordinate, opt_fractionDigits?: number): string;
}
/**
* @classdesc
* The ol.DeviceOrientation class provides access to information from
* DeviceOrientation events. See the [HTML 5 DeviceOrientation Specification](
* http://www.w3.org/TR/orientation-event/) for more details.
*
* Many new computers, and especially mobile phones
* and tablets, provide hardware support for device orientation. Web
* developers targeting mobile devices will be especially interested in this
* class.
*
* Device orientation data are relative to a common starting point. For mobile
* devices, the starting point is to lay your phone face up on a table with the
* top of the phone pointing north. This represents the zero state. All
* angles are then relative to this state. For computers, it is the same except
* the screen is open at 90 degrees.
*
* Device orientation is reported as three angles - `alpha`, `beta`, and
* `gamma` - relative to the starting position along the three planar axes X, Y
* and Z. The X axis runs from the left edge to the right edge through the
* middle of the device. Similarly, the Y axis runs from the bottom to the top
* of the device through the middle. The Z axis runs from the back to the front
* through the middle. In the starting position, the X axis points to the
* right, the Y axis points away from you and the Z axis points straight up
* from the device lying flat.
*
* The three angles representing the device orientation are relative to the
* three axes. `alpha` indicates how much the device has been rotated around the
* Z axis, which is commonly interpreted as the compass heading (see note
* below). `beta` indicates how much the device has been rotated around the X
* axis, or how much it is tilted from front to back. `gamma` indicates how
* much the device has been rotated around the Y axis, or how much it is tilted
* from left to right.
*
* For most browsers, the `alpha` value returns the compass heading so if the
* device points north, it will be 0. With Safari on iOS, the 0 value of
* `alpha` is calculated from when device orientation was first requested.
* ol.DeviceOrientation provides the `heading` property which normalizes this
* behavior across all browsers for you.
*
* It is important to note that the HTML 5 DeviceOrientation specification
* indicates that `alpha`, `beta` and `gamma` are in degrees while the
* equivalent properties in ol.DeviceOrientation are in radians for consistency
* with all other uses of angles throughout OpenLayers.
*
* To get notified of device orientation changes, register a listener for the
* generic `change` event on your `ol.DeviceOrientation` instance.
*
* @see {@link http://www.w3.org/TR/orientation-event/}
*
* @param opt_options Options.
* @api
*/
export class DeviceOrientation extends Object {
/**
* @classdesc
* The ol.DeviceOrientation class provides access to information from
* DeviceOrientation events. See the [HTML 5 DeviceOrientation Specification](
* http://www.w3.org/TR/orientation-event/) for more details.
*
* Many new computers, and especially mobile phones
* and tablets, provide hardware support for device orientation. Web
* developers targeting mobile devices will be especially interested in this
* class.
*
* Device orientation data are relative to a common starting point. For mobile
* devices, the starting point is to lay your phone face up on a table with the
* top of the phone pointing north. This represents the zero state. All
* angles are then relative to this state. For computers, it is the same except
* the screen is open at 90 degrees.
*
* Device orientation is reported as three angles - `alpha`, `beta`, and
* `gamma` - relative to the starting position along the three planar axes X, Y
* and Z. The X axis runs from the left edge to the right edge through the
* middle of the device. Similarly, the Y axis runs from the bottom to the top
* of the device through the middle. The Z axis runs from the back to the front
* through the middle. In the starting position, the X axis points to the
* right, the Y axis points away from you and the Z axis points straight up
* from the device lying flat.
*
* The three angles representing the device orientation are relative to the
* three axes. `alpha` indicates how much the device has been rotated around the
* Z axis, which is commonly interpreted as the compass heading (see note
* below). `beta` indicates how much the device has been rotated around the X
* axis, or how much it is tilted from front to back. `gamma` indicates how
* much the device has been rotated around the Y axis, or how much it is tilted
* from left to right.
*
* For most browsers, the `alpha` value returns the compass heading so if the
* device points north, it will be 0. With Safari on iOS, the 0 value of
* `alpha` is calculated from when device orientation was first requested.
* ol.DeviceOrientation provides the `heading` property which normalizes this
* behavior across all browsers for you.
*
* It is important to note that the HTML 5 DeviceOrientation specification
* indicates that `alpha`, `beta` and `gamma` are in degrees while the
* equivalent properties in ol.DeviceOrientation are in radians for consistency
* with all other uses of angles throughout OpenLayers.
*
* To get notified of device orientation changes, register a listener for the
* generic `change` event on your `ol.DeviceOrientation` instance.
*
* @see {@link http://www.w3.org/TR/orientation-event/}
*
* @param opt_options Options.
* @api
*/
constructor(opt_options?: olx.DeviceOrientationOptions);
/**
* Rotation around the device z-axis (in radians).
* @return The euler angle in radians of the device from the
* standard Z axis.
* @observable
* @api
*/
getAlpha(): number;
/**
* Rotation around the device x-axis (in radians).
* @return The euler angle in radians of the device from the
* planar X axis.
* @observable
* @api
*/
getBeta(): number;
/**
* Rotation around the device y-axis (in radians).
* @return The euler angle in radians of the device from the
* planar Y axis.
* @observable
* @api
*/
getGamma(): number;
/**
* The heading of the device relative to north (in radians).
* @return The heading of the device relative to north, in
* radians, normalizing for different browser behavior.
* @observable
* @api
*/
getHeading(): number;
/**
* Determine if orientation is being tracked.
* @return Changes in device orientation are being tracked.
* @observable
* @api
*/
getTracking(): boolean;
/**
* Enable or disable tracking of device orientation events.
* @param tracking The status of tracking changes to alpha, beta and
* gamma. If true, changes are tracked and reported immediately.
* @observable
* @api
*/
setTracking(tracking: boolean): void;
}
/**
* Objects that need to clean up after themselves.
*/
/* tslint:disable-next-line:no-unnecessary-class */
export class Disposable {
/**
* Objects that need to clean up after themselves.
*/
constructor();
}
/**
* Easing functions for {@link ol.animation}.
*/
export namespace easing {
/**
* Start slow and speed up.
* @param t Input between 0 and 1.
* @return Output between 0 and 1.
* @api
*/
function easeIn(t: number): number;
/**
* Start fast and slow down.
* @param t Input between 0 and 1.
* @return Output between 0 and 1.
* @api
*/
function easeOut(t: number): number;
/**
* Start slow, speed up, and then slow down again.
* @param t Input between 0 and 1.
* @return Output between 0 and 1.
* @api
*/
function inAndOut(t: number): number;
/**
* Maintain a constant speed over time.
* @param t Input between 0 and 1.
* @return Output between 0 and 1.
* @api
*/
function linear(t: number): number;
/**
* Start slow, speed up, and at the very end slow down again. This has the
* same general behavior as {@link ol.easing.inAndOut}, but the final slowdown
* is delayed.
* @param t Input between 0 and 1.
* @return Output between 0 and 1.
* @api
*/
function upAndDown(t: number): number;
}
/**
* Applications do not normally create event instances. They register (and
* unregister) event listener functions, which, when called by the library as
* the result of an event being dispatched, are passed event instances as their
* first argument. Listeners can be registered and unregistered on all objects
* descending from {@link ol.Observable}. All event instances have a `target`
* property, which corresponds to the object on which the event was dispatched.
* By default, `this` within the listener also refers to the target, though
* this can be configured in the listener registration function.
* Some classes have their own event type, which return additional
* properties; see the specific event class page for details.
*/
export namespace events {
namespace condition {
/**
* Return `true` if only the alt-key is pressed, `false` otherwise (e.g. when
* additionally the shift-key is pressed).
*
* @param mapBrowserEvent Map browser event.
* @return True if only the alt key is pressed.
* @api stable
*/
function altKeyOnly(mapBrowserEvent: ol.MapBrowserEvent): boolean;
/**
* Return `true` if only the alt-key and shift-key is pressed, `false` otherwise
* (e.g. when additionally the platform-modifier-key is pressed).
*
* @param mapBrowserEvent Map browser event.
* @return True if only the alt and shift keys are pressed.
* @api stable
*/
function altShiftKeysOnly(mapBrowserEvent: ol.MapBrowserEvent): boolean;
/**
* Return always true.
*
* @param mapBrowserEvent Map browser event.
* @return True.
* @api stable
*/
function always(mapBrowserEvent: ol.MapBrowserEvent): boolean;
/**
* Return `true` if the event is a `click` event, `false` otherwise.
*
* @param mapBrowserEvent Map browser event.
* @return True if the event is a map `click` event.
* @api stable
*/
function click(mapBrowserEvent: ol.MapBrowserEvent): boolean;
/**
* Return always false.
*
* @param mapBrowserEvent Map browser event.
* @return False.
* @api stable
*/
function never(mapBrowserEvent: ol.MapBrowserEvent): boolean;
/**
* Return `true` if the browser event is a `pointermove` event, `false`
* otherwise.
*
* @param mapBrowserEvent Map browser event.
* @return True if the browser event is a `pointermove` event.
* @api
*/
function pointerMove(mapBrowserEvent: ol.MapBrowserEvent): boolean;
/**
* Return `true` if the event is a map `singleclick` event, `false` otherwise.
*
* @param mapBrowserEvent Map browser event.
* @return True if the event is a map `singleclick` event.
* @api stable
*/
function singleClick(mapBrowserEvent: ol.MapBrowserEvent): boolean;
/**
* Return `true` if the event is a map `dblclick` event, `false` otherwise.
*
* @param mapBrowserEvent Map browser event.
* @return True if the event is a map `dblclick` event.
* @api stable
*/
function doubleClick(mapBrowserEvent: ol.MapBrowserEvent): boolean;
/**
* Return `true` if no modifier key (alt-, shift- or platform-modifier-key) is
* pressed.
*
* @param mapBrowserEvent Map browser event.
* @return True only if there no modifier keys are pressed.
* @api stable
*/
function noModifierKeys(mapBrowserEvent: ol.MapBrowserEvent): boolean;
/**
* Return `true` if only the platform-modifier-key (the meta-key on Mac,
* ctrl-key otherwise) is pressed, `false` otherwise (e.g. when additionally
* the shift-key is pressed).
*
* @param mapBrowserEvent Map browser event.
* @return True if only the platform modifier key is pressed.
* @api stable
*/
function platformModifierKeyOnly(mapBrowserEvent: ol.MapBrowserEvent): boolean;
/**
* Return `true` if only the shift-key is pressed, `false` otherwise (e.g. when
* additionally the alt-key is pressed).
*
* @param mapBrowserEvent Map browser event.
* @return True if only the shift key is pressed.
* @api stable
*/
function shiftKeyOnly(mapBrowserEvent: ol.MapBrowserEvent): boolean;
/**
* Return `true` if the target element is not editable, i.e. not a `<input>`-,
* `<select>`- or `<textarea>`-element, `false` otherwise.
*
* @param mapBrowserEvent Map browser event.
* @return True only if the target element is not editable.
* @api
*/
function targetNotEditable(mapBrowserEvent: ol.MapBrowserEvent): boolean;
/**
* Return `true` if the event originates from a mouse device.
*
* @param mapBrowserEvent Map browser event.
* @return True if the event originates from a mouse device.
* @api stable
*/
function mouseOnly(mapBrowserEvent: ol.MapBrowserEvent): boolean;
/**
* Return `true` if the event originates from a primary pointer in
* contact with the surface or if the left mouse button is pressed.
* @see http://www.w3.org/TR/pointerevents/#button-states
*
* @param mapBrowserEvent Map browser event.
* @return True if the event originates from a primary pointer.
* @api
*/
function primaryAction(mapBrowserEvent: ol.MapBrowserEvent): boolean;
}
/**
* @classdesc
* Stripped down implementation of the W3C DOM Level 2 Event interface.
* @see {@link https://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-interface}
*
* This implementation only provides `type` and `target` properties, and
* `stopPropagation` and `preventDefault` methods. It is meant as base class
* for higher level events defined in the library, and works with
* {@link ol.events.EventTarget}.
*
* @param type Type.
*/
class Event {
/**
* @classdesc
* Stripped down implementation of the W3C DOM Level 2 Event interface.
* @see {@link https://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-interface}
*
* This implementation only provides `type` and `target` properties, and
* `stopPropagation` and `preventDefault` methods. It is meant as base class
* for higher level events defined in the library, and works with
* {@link ol.events.EventTarget}.
*
* @param type Type.
*/
constructor(type: string);
/**
* The event type.
* @api stable
*/
type: string;
/**
* The event target.
* @api stable
*/
target: GlobalObject;
/**
* Stop event propagation.
* @api stable
*/
preventDefault(): void;
/**
* Stop event propagation.
* @api stable
*/
stopPropagation(): void;
}
/**
* @classdesc
* A simplified implementation of the W3C DOM Level 2 EventTarget interface.
* @see {@link https://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-EventTarget}
*
* There are two important simplifications compared to the specification:
*
* 1. The handling of `useCapture` in `addEventListener` and
* `removeEventListener`. There is no real capture model.
* 2. The handling of `stopPropagation` and `preventDefault` on `dispatchEvent`.
* There is no event target hierarchy. When a listener calls
* `stopPropagation` or `preventDefault` on an event object, it means that no
* more listeners after this one will be called. Same as when the listener
* returns false.
*/
class EventTarget extends Disposable {
/**
* @classdesc
* A simplified implementation of the W3C DOM Level 2 EventTarget interface.
* @see {@link https://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-EventTarget}
*
* There are two important simplifications compared to the specification:
*
* 1. The handling of `useCapture` in `addEventListener` and
* `removeEventListener`. There is no real capture model.
* 2. The handling of `stopPropagation` and `preventDefault` on `dispatchEvent`.
* There is no event target hierarchy. When a listener calls
* `stopPropagation` or `preventDefault` on an event object, it means that no
* more listeners after this one will be called. Same as when the listener
* returns false.
*/
constructor();
}
}
/* From ol/typedefs.js */
export type EventsListenerFunctionType = ((evt: ol.events.Event) => void) | ((evt: ol.events.Event) => boolean);
export namespace extent {
/**
* Build an extent that includes all given coordinates.
*
* @param coordinates Coordinates.
* @return Bounding extent.
* @api stable
*/
function boundingExtent(coordinates: ol.Coordinate[]): ol.Extent;
/**
* Return extent increased by the provided value.
* @param extent Extent.
* @param value The amount by which the extent should be buffered.
* @param opt_extent Extent.
* @return Extent.
* @api stable
*/
function buffer(extent: ol.Extent, value: number, opt_extent?: ol.Extent): ol.Extent;
/**
* Check if the passed coordinate is contained or on the edge of the extent.
*
* @param extent Extent.
* @param coordinate Coordinate.
* @return The coordinate is contained in the extent.
* @api stable
*/
function containsCoordinate(extent: ol.Extent, coordinate: ol.Coordinate): boolean;
/**
* Check if one extent contains another.
*
* An extent is deemed contained if it lies completely within the other extent,
* including if they share one or more edges.
*
* @param extent1 Extent 1.
* @param extent2 Extent 2.
* @return The second extent is contained by or on the edge of the
* first.
* @api stable
*/
function containsExtent(extent1: ol.Extent, extent2: ol.Extent): boolean;
/**
* Check if the passed coordinate is contained or on the edge of the extent.
*
* @param extent Extent.
* @param x X coordinate.
* @param y Y coordinate.
* @return The x, y values are contained in the extent.
* @api stable
*/
function containsXY(extent: ol.Extent, x: number, y: number): boolean;
/**
* Create an empty extent.
* @return Empty extent.
* @api stable
*/
function createEmpty(): ol.Extent;
/**
* Determine if two extents are equivalent.
* @param extent1 Extent 1.
* @param extent2 Extent 2.
* @return The two