azure-maps-control
Version:
Map SDK for Azure Maps
1,133 lines (1,039 loc) • 274 kB
TypeScript
import {PublicClientApplication} from "@azure/msal-browser";
import {DataDrivenPropertyValueSpecification, PropertyValueSpecification, ExpressionFilterSpecification} from "@maplibre/maplibre-gl-style-spec";
type PositionAnchor = "center" | "top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right";
type Position = atlas.data.Position;
declare namespace atlas {
//data classes
export module data {
/**
* A GeoJSON Position object - an array that specifies the longitude and latitude of a location. The
* full description is detailed in [RFC 7946]{@link https://tools.ietf.org/html/rfc7946#section-3.1.1}.
*/
export class Position extends Array<number> {
/**
* Constructs a Position.
* @param longitude The position's longitude.
* @param latitude The position's latitude.
* @param elevation The position's elevation.
*/
constructor (longitude: number, latitude: number, elevation?: number);
/**
* Clones a position.
* @param position The position to clone.
*/
static fromPosition (position: Position): Position;
/**
* Compares the longitude and latitude values of two positions to see if they are equal at an accuracy of 6 decimal places.
* @param pos1 First position to compare.
* @param pos2 Second position to compare.
* @param precision The number of decimal places to compare to. Default: 6.
* @returns A boolean indicating if two positions to see if they are equal at an accuracy of the specified precision or 6 decimal places.
*/
static areEqual (pos1: Position, pos2: Position, precision?: number): boolean;
/**
* Generates a Position object from an object that contains coordinate information.
* The object is scanned for the following properties using a case insensitive test.
* Longitude: lng, longitude, lon, x
* Latitude: lat, latitude, y
* Elevation: elv, elevation, alt, altitude, z
* @param latLng The object to extract coordinate information from.
* @returns A Position object that represents the provided LatLng information.
*/
static fromLatLng (latLng: object): Position;
/**
* Generates a Position object from latitude and longitude values.
* @param lat The latitude value.
* @param lng A longitude value.
* @param elv An elevation value in meters.
* @returns A Position object that represents the provided LatLng information.
*/
static fromLatLng (lat: number, lng: number, elv?: number): Position;
/**
* Generates a Position object from an array that has the format; [lat, lng] or [lat, lng, elv]
* @param latLng An array that contains latitude/longitude information in the format; [lat, lng] or [lat, lng, elv]
* @returns A Position object that represents the provided LatLng information.
*/
static fromLatLng (latLng: number[]): Position;
/**
* Converts an array of objects that contain coordinate information into an array of Positions. Objects that can't be converted are discarded.
* Each object is either an array in the format; [lat, lng] or [lat, lng, elv], or an object with the any combination of the following properties:
* Longitude: lng, longitude, lon, x
* Latitude: lat, latitude, y
* Elevation: elv, elevation, alt, altitude, z
* @param latLngs The objects that contain coordinate information.
* @returns An array of Position objects that contain all the provided coordinate information.
*/
static fromLatLngs (latLngs: Array<object | number[]>): Position[];
}
/**
* A GeoJSON BoundingBox object - an array that defines a shape whose edges follow lines of constant longitude,
* latitude, and elevation. All axes of the most southwesterly point are followed by all axes of the more northeasterly
* point. The axes order of the BoundingBox follows the axes order of geometries. The full description is detailed in
* [RFC 7946]{@link https://tools.ietf.org/html/rfc7946#section-5}.
*/
export class BoundingBox extends Array<number> {
/**
* Constructs a BoundingBox
* @param positions Can be either [west, south, east, north] or [west, south, elevation1, east, north, elevation2]
*/
constructor (positions: number[]);
/**
* Constructs a BoundingBox.
* @param southwestPosition The southwestern most position of the bounding box.
* @param northeastPosition The northeastern most position of the bounding box.
*/
constructor (southwestPosition: Position, northeastPosition: Position);
/**
* Clones a bounding box.
* @param boundingBox The bounding box to clone.
*/
static fromBoundingBox (boundingBox: BoundingBox): BoundingBox;
/**
* Constructs a BoundingBox from the specified dimensions.
* @param center The center position of the bounding box.
* @param width The width of the bounding box.
* @param height The height of the bounding box.
*/
static fromDimensions (center: Position, width: number, height: number): BoundingBox;
/**
* Constructs a BoundingBox from the specified edges.
* @param west The west edge of the bounding box.
* @param south The south edge of the bounding box.
* @param east The east edge of the bounding box.
* @param north The north edge of the bounding box.
*/
static fromEdges (west: number, south: number, east: number, north: number): BoundingBox;
/**
* Determines if a position is within a bounding box.
* @param bounds The bounding box to see if the position is in.
* @param position The position to see if it is in the bounding box.
* @returns True if the position is within the bounding box.
*/
static containsPosition (bounds: BoundingBox, position: Position): boolean;
/**
* Returns a boolean indicating if the bounding box crosses the antimeridian or not.
* @param bounds The bounding box to check.
* @returns A boolean indicating if the bounding box crosses the antimeridian or not.
*/
static crossesAntimeridian (bounds: BoundingBox): boolean;
/**
* Calculates the center of a bounding box.
* @param bounds A bounding box to calculate the center of.
* @returns A position that represents the center of the bounding box.
*/
static getCenter (bounds: BoundingBox): Position;
/**
* Gets the height of a bounding box in degrees.
* @param bounds The bounding box to check.
* @returns The height of the bounding box in degrees.
*/
static getHeight (bounds: BoundingBox): number;
/**
* Gets the width of a bounding box in degrees.
* @param bounds The bounding box to check.
* @returns The width of the bounding box in degrees.
*/
static getWidth (bounds: BoundingBox): number;
/**
* Returns the south west position of the bounding box.
* @param bounds The bounding box to get the position from.
* @returns The south west position of the bounding box.
*/
static getSouthWest (bounds: BoundingBox): Position;
/**
* Returns the north east position of the bounding box.
* @param bounds The bounding box to get the position from.
* @returns The north east position of the bounding box.
*/
static getNorthEast (bounds: BoundingBox): Position;
/**
* Returns the north west position of the bounding box.
* @param bounds The bounding box to get the position from.
* @returns The north west position of the bounding box.
*/
static getNorthWest (bounds: BoundingBox): Position;
/**
* Returns the south east position of the bounding box.
* @param bounds The bounding box to get the position from.
* @returns The south east position of the bounding box.
*/
static getSouthEast (bounds: BoundingBox): Position;
/**
* Returns the south position value of the bounding box.
* @param bounds The bounding box to get the position from.
* @returns The south position value of the bounding box.
*/
static getSouth (bounds: BoundingBox): number;
/**
* Returns the west position value of the bounding box.
* @param bounds The bounding box to get the position from.
* @returns The west position value of the bounding box.
*/
static getWest (bounds: BoundingBox): number;
/**
* Returns the north position value of the bounding box.
* @param bounds The bounding box to get the position from.
* @returns The north position value of the bounding box.
*/
static getNorth (bounds: BoundingBox): number;
/**
* Returns the east position value of the bounding box.
* @param bounds The bounding box to get the position from.
* @returns The east position value of the bounding box.
*/
static getEast (bounds: BoundingBox): number;
/**
* Determines is two bounding boxes intersect.
* @param bounds1 The first bounding box to compare with.
* @param bounds2 The second bounding box to compare with.
* @returns true if the provided bounding boxes intersect.
*/
static intersect (bounds1: BoundingBox, bounds2: BoundingBox): boolean;
/**
* Merges two bounding boxes together.
* @param bounds1 The first bounding box to merge with.
* @param bounds2 The second bounding box to merge with.
* @returns A bounding box in the format [minLon, minLat, maxLon, maxLat].
*/
static merge (bounds1: BoundingBox, bounds2: BoundingBox): BoundingBox;
/**
* Creates a BoundingBox that contains all provided Position objects.
* @param positions An array of locations to use to generate the bounding box.
* @returns A bounding box that contains all given positions.
*/
static fromPositions (positions: Position[]): BoundingBox;
/**
* Creates a BoundingBox from any array of objects that contain coordinate information.
* Each object is either an array in the format; [lat, lng] or [lat, lng, elv], or an object with the any combination of the following properties:
* Longitude: lng, longitude, lon, x
* Latitude: lat, latitude, y
* Elevation: elv, elevation, alt, altitude, z
* @param latLngs The objects that contain coordinate information.
* @returns A BoundingBox that contains all the provided coordinate information.
*/
static fromLatLngs (latLngs: Array<object | number[]>): BoundingBox;
/**
* Calculates the bounding box of a FeatureCollection, Feature, Geometry, Shape or array of these objects.
* @param data The FeatureCollection, Feature, Geometry, Shape or array of these objects to calculate the bounding box for.
* @returns A bounding box in the format [minLon, minLat, maxLon, maxLat].
*/
static fromData (data: FeatureCollection | Feature<Geometry, any> | Geometry | Shape | Array<FeatureCollection | Feature<Geometry, any> | Geometry | Shape>): BoundingBox;
/**
* Splits a BoundingBox that crosses the Antimeridian into two BoundingBox's. One entirely west of the Antimerdian and another entirely east of the Antimerdian.
* @param bounds
*/
static splitOnAntimeridian (bounds: BoundingBox): BoundingBox[];
}
/**
* A base Geometry object in which all geometry shapes extend; Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, GeometryCollection
*/
export type Geometry = Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon;
/**
* A GeoJSON FeatureCollection object - a JSON object that contains a collection of GeoJSON features. The full
* description is detailed in [RFC 7946]{@link https://tools.ietf.org/html/rfc7946#section-3.3}.
*/
export class FeatureCollection {
/**
* A static GeoJSON type descriptor for the FeatureCollection class to be used in runtime comparisons.
*/
static readonly TYPE: string;
/**
* A GeoJSON type descriptor with value "FeatureCollection".
*/
type: string;
/**
* The collection of GeoJSON features contained in the feature collection.
*/
features: Array<Feature<Geometry, any>>;
/**
* The bounding box of the feature collection.
*/
bbox?: BoundingBox;
/**
* Constructs a FeatureCollection.
* @param features The collection of features that make up the feature collection.
* @param bbox The bounding box of the feature collection.
*/
constructor (features: Array<Feature<Geometry, any>>, bbox?: BoundingBox);
}
/**
* A GeoJSON Feature object - a JSON object representing a spatially bounded entity. The full description is detailed in
* [RFC 7946]{@link https://tools.ietf.org/html/rfc7946#section-3.2}.
*/
export class Feature<G extends Geometry, P extends any> {
/**
* A static GeoJSON type descriptor for the Feature class to be used in runtime comparisons.
*/
static readonly TYPE: string;
/**
* A GeoJSON type descriptor with value "Feature".
*/
type: string;
/**
* The geometry of the feature.
*/
geometry: G;
/**
* The bounding box of the feature.
*/
bbox?: BoundingBox;
/**
* The properties of the feature.
*/
properties?: P;
/**
* The id of the feature.
*/
id?: string | number;
/**
* Constructs a Feature.
* @param geometry The geometry of the feature.
* @param properties The properties of the feature.
* @param id The id of the feature.
* @param bbox The bounding box of the feature.
*/
constructor (geometry: G, properties?: P, id?: string | number, bbox?: BoundingBox);
}
/**
* A GeoJSON Point object - a JSON object that represents a geographic position. The full description is detailed in
* [RFC 7946]{@link https://tools.ietf.org/html/rfc7946#section-3.1.2}.
*/
export class Point {
/**
* A static GeoJSON type descriptor for the Point class to be used in runtime comparisons.
*/
static readonly TYPE: string;
/**
* A GeoJSON type descriptor with value "Point".
*/
readonly type: string;
/**
* The position defining the point.
*/
coordinates: Position;
/**
* Constructs a Point.
* @param coordinates The position defining the point.
*/
constructor (coordinates: Position);
}
/**
* A GeoJSON LineString object - a JSON object that represents a geographic curve. The full description is detailed
* in [RFC 7946]{@link https://tools.ietf.org/html/rfc7946#section-3.1.4}.
*/
export class LineString {
/**
* A static GeoJSON type descriptor for the LineString class to be used in runtime comparisons.
*/
static readonly TYPE: string;
/**
* A GeoJSON type descriptor with value "LineString".
*/
readonly type: string;
/**
* The ordered list of positions defining the linestring.
*/
coordinates: Position[];
/**
* The bounding box of the linestring.
*/
bbox?: BoundingBox;
/**
* Constructs a LineString.
* @param coordinates The ordered list of positions defining the linestring.
* @param bbox The bounding box of the linestring.
*/
constructor (coordinates: Position[], bbox?: BoundingBox);
}
/**
* A GeoJSON Polygon object - a JSON object that represents a geographic polygon. The full description is detailed in
* [RFC 7946]{@link https://tools.ietf.org/html/rfc7946#section-3.1.6}.
*/
export class Polygon {
/**
* A static GeoJSON type descriptor for the Polygon class to be used in runtime comparisons.
*/
static readonly TYPE: string;
/**
* A GeoJSON type descriptor with value "Polygon".
*/
type: string;
/**
* The array of linear ring coordinate arrays defining the polygon.
*/
coordinates: Position[][];
/**
* The bounding box of the polygon.
*/
bbox?: BoundingBox;
/**
* Constructs a Polygon.
* @param coordinates The array of linear ring coordinate arrays defining the polygon.
* @param bbox The bounding box of the polygon.
*/
constructor (coordinates: Position[][] | Position[], bbox?: BoundingBox);
}
/**
* A GeoJSON MultiPoint object - a JSON object that represents multiple geographic positions. The full description
* is detailed in [RFC 7946]{@link https://tools.ietf.org/html/rfc7946#section-3.1.3}.
*/
export class MultiPoint {
/**
* A static GeoJSON type descriptor for the MultiPoint class to be used in runtime comparisons.
*/
public static readonly TYPE: string;
/**
* A GeoJSON type descriptor with value "MutliPoint".
*/
public type: string;
/**
* The array of multiple positions defining the multipoint.
*/
public coordinates: Position[];
/**
* The bounding box of the multipoint.
*/
public bbox?: BoundingBox;
/**
* Constructs a MultiPoint.
* @param coordinates The array of multiple positions defining the multipoint.
* @param bbox The bounding box of the multipoint.
*/
constructor (coordinates: Position[], bbox?: BoundingBox);
}
/**
* A GeoJSON MultiLineString object - a JSON object that represents multiple geographic curves. The full description
* is detailed in [RFC 7946]{@link https://tools.ietf.org/html/rfc7946#section-3.1.5}.
*/
export class MultiLineString {
/**
* A static GeoJSON type descriptor for the MultiLineString class to be used in runtime comparisons.
*/
public static readonly TYPE: string;
/**
* A GeoJSON type descriptor with value "MutliLineString".
*/
public type: string;
/**
* The array of LineString coordinate arrays defining the multilinestring.
*/
public coordinates: Position[][];
/**
* The bounding box of the multilinestring.
*/
public bbox?: BoundingBox;
/**
* Constructs a MultiLineString.
* @param coordinates The array of LineString coordinate arrays defining the multilinestring.
* @param bbox The bounding box of the multilinestring.
*/
constructor (coordinates: Position[][], bbox?: BoundingBox);
}
/**
* A GeoJSON MultiPolygon object - a JSON object that represents multiple geographic polygons. The full description is
* detailed in [RFC 7946]{@link https://tools.ietf.org/html/rfc7946#section-3.1.7}.
*/
export class MultiPolygon {
/**
* A static GeoJSON type descriptor for the MultiPolygon class to be used in runtime comparisons.
*/
public static readonly TYPE: string;
/**
* A GeoJSON type descriptor with value "MutliPolygon".
*/
public type: string;
/**
* The array of polygon coordinate arrays defining the multipolygon.
*/
public coordinates: Position[][][];
/**
* The bounding box of the multipolygon.
*/
public bbox?: BoundingBox;
/**
* Constructs a MultiPolygon.
* @param coordinates The array of polygon coordinate arrays defining the multipolygon.
* @param bbox The bounding box of the multipolygon.
*/
constructor (coordinates: Position[][][], bbox?: BoundingBox);
}
/**
* A GeoJSON GeometryCollection object - a JSON object that contains a collection of a GeoJSON Geometry objects. The
* full description is detailed in [RFC 7946]{@link https://tools.ietf.org/html/rfc7946#section-3.1.8}.
*/
export class GeometryCollection {
/**
* A static GeoJSON type descriptor for the GeometryCollection class to be used in runtime comparisons.
*/
static readonly TYPE: string;
/**
* A GeoJSON type descriptor with value "GeometryCollection".
*/
type: string;
/**
* The collection of GeoJSON geometries contained in the geometry collection.
*/
geometries: Geometry[];
/**
* Constructs a GeometryCollection.
* @param geometries The collection of geometries that make up the geometry collection.
*/
constructor (geometries: Geometry[]);
}
/**
* A `MercatorPoint` object represents a projected three dimensional position.
*
* `MercatorPoint` uses the web mercator projection ([EPSG:3857](https://epsg.io/3857)) with slightly different units:
* - the size of 1 unit is the width of the projected world instead of the "mercator meter"
* - the origin of the coordinate space is at the north-west corner instead of the middle.
*
* For example, `MercatorPoint(0, 0, 0)` is the north-west corner of the mercator world and
* `MercatorPoint(1, 1, 0)` is the south-east corner. If you are familiar with
* [vector tiles](https://github.com/mapbox/vector-tile-spec) it may be helpful to think
* of the coordinate space as the `0/0/0` tile with an extent of `1`.
*
* The `z` dimension of `MercatorPoint` is conformal. A cube in the mercator coordinate space would be rendered as a cube.
*/
export class MercatorPoint extends Array<number> {
/**
* Constructs a MercatorPoint.
* @param x A points x position in mercator units.
* @param y A points y position in mercator units.
* @param z A points z position in mercator units.
*/
constructor (x: number, y: number, z?: number);
/**
* Converts a position into a mercator point.
* @param position Position to convert.
* @returns A mercator point.
*/
static fromPosition (position: Position): MercatorPoint;
/**
* Converts an array of positions into an array of mercator points.
* @param positions Array of positions to convert.
* @returns An array of mercator points.
*/
static fromPositions (positions: Position[]): MercatorPoint[];
/**
* Converts an array of positions into a Float32Array of mercator xyz values.
* @param positions Array of positions to convert.
* @returns A Float32Array of mercator xyz values.
*/
static toFloat32Array (positions: Position[]): Float32Array;
/**
* Converts a mercator point into a map position.
* @param mercator Mercator point to convert.
* @returns A map position.
*/
static toPosition (mercator: MercatorPoint): Position;
/**
* Converts an array of mercator points into an array of map positions.
* @param mercators Mercator points to convert.
* @returns An array of map positions.
*/
static toPositions (mercators: MercatorPoint[]): Position[];
/**
* Determine the Mercator scale factor for a given latitude, see
* https://en.wikipedia.org/wiki/Mercator_projection#Scale_factor
*
* At the equator the scale factor will be 1, which increases at higher latitudes.
*
* @param latitude Latitude
* @returns The mercator scale factor.
*/
static mercatorScale (latitude: number): number;
/**
* Returns the distance of 1 meter in `MercatorPoint` units at this latitude.
*
* For coordinates in real world units using meters, this naturally provides the scale
* to transform into `MercatorPoint`s.
*
* @returns {number} Distance of 1 meter in `MercatorPoint` units.
*/
static meterInMercatorUnits (latitude: number): number;
}
}
//control classes
export module control {
/** The events supported by the `StyleControl`. */
export interface StyleControlEvents {
/** Event fired when a style is clicked. Returns the style name been clicked. */
styleselected: string;
}
/**
* Implements control interface and provides support for automatic styling based on the map style.
*/
export abstract class ControlBase<T = any> extends internal.EventEmitter<T> implements Control {
/**
* Initialization method for the control which is called when added to the map.
* @param map The map that the control will be added to.
* @param options The ControlOptions for this control.
* @return An HTMLElement to be placed on the map for the control.
*/
abstract onAdd (map: Map, options?: ControlOptions): HTMLElement;
/**
* Method that is called when the control is removed from the map. Should perform any necessary cleanup for the
* control.
*/
onRemove (): void;
/**
* Build the outermost container for the control, applies styling including any listeners for auto styling.
*/
buildContainer<K extends keyof HTMLElementTagNameMap = "div">(map: Map, style: ControlStyle, ariaLabel?: string, tagName?: K): HTMLElementTagNameMap[K];
}
/**
* A control for changing the rotation of the map.
*/
export class CompassControl extends ControlBase {
protected static DefaultRotation: number;
protected static InvertOrderPositions: ControlPosition[2];
protected hasMouse: boolean;
protected hasFocus: boolean;
protected lastActiveTime: number;
protected options: CompassControlOptions;
/**
* Constructs a CompassControl.
* @param options The options for the control.
*/
constructor (options?: CompassControlOptions);
/**
* Initialization method for the control which is called when added to the map.
* @param map The map that the control will be added to.
* @param options The ControlOptions for this control.
* @return An HTMLElement to be placed on the map for the control.
*/
onAdd (map: Map, options?: ControlOptions): HTMLElement;
protected constructRotationGrid: (map: Map, options?: ControlOptions) => HTMLElement;
protected constructRotationButton: (map: Map) => HTMLElement;
protected constructRightRotationButton: (map: Map) => HTMLElement;
protected constructLeftRotationButton: (map: Map) => HTMLElement;
}
/**
* A control for changing the pitch of the map.
*/
export class PitchControl extends ControlBase {
protected static PITCH_DURATION_MS: number;
protected static DEFAULT_PITCH: number;
protected static INVERT_ORDER_POSITIONS: ControlPosition[];
protected container: HTMLDivElement | null;
protected map: Map | null;
protected pitchButton: HTMLButtonElement | null;
protected pitchIncrementButton: HTMLButtonElement | null;
protected pitchDecrementButton: HTMLButtonElement | null;
protected hasMouse: boolean;
protected hasFocus: boolean;
protected lastActiveTime: number;
protected options: PitchControlOptions;
/**
* Constructs a PitchControl.
* @param options The options for the control.
*/
constructor (options?: PitchControlOptions);
/**
* Initialization method for the control which is called when added to the map.
* @param map The map that the control will be added to.
* @param options The ControlOptions for this control.
* @return An HTMLElement to be placed on the map for the control.
*/
onAdd (map: Map, options?: ControlOptions): HTMLElement;
onRemove (): void;
protected pitchChanged: (map: MapEvent) => void;
protected updatePitchButtonsState: () => void;
protected constructPitchGrid: (map: Map, options?: ControlOptions) => void;
protected constructPitchButton: (map: Map) => HTMLElement;
protected constructPitchDecrementButton: (map: Map) => HTMLElement;
protected constructPitchIncrementButton: (map: Map) => HTMLElement;
}
/**
* A control to display a scale bar on the map.
*/
export class ScaleControl extends ControlBase {
private map: Map | null;
private control;
/**
* Constructs a ScaleControl.
* @param options The options for the control.
*/
constructor (options?: ScaleControlOptions);
/**
* Initialization method for the control which is called when added to the map.
* @param map The map that the control will be added to.
* @param options The ControlOptions for this control.
* @return An HTMLElement to be placed on the map for the control.
*/
onAdd (map: Map, options?: ControlOptions): HTMLElement;
/**
* Method that is called when the control is removed from the map. Should perform any necessary cleanup for the
* control.
*/
onRemove (): void;
/**
* Set the scale's unit of the distance
* @param unit - Unit of the distance (`'imperial'`, `'metric'` or `'nautical'`).
*/
setUnit (unit: "imperial" | "metric" | "nautical"): void;
}
/**
* A control for changing the style of the map.
*/
export class StyleControl extends ControlBase<StyleControlEvents> {
private static readonly InvertOrderPositions;
private static readonly Css;
private map;
private options;
private currStyleImage;
private styleIcons;
/**
* Constructs a StyleControl.
* @param options The options for the control.
*/
constructor (options?: StyleControlOptions);
/**
* Initialization method for the control which is called when added to the map.
* @param map The map that the control will be added to.
* @param options The ControlOptions for this control.
* @return An HTMLElement to be placed on the map for the control.
*/
onAdd (map: Map, options?: ControlOptions): HTMLElement;
/**
* Method that is called when the control is removed from the map. Should perform any necessary cleanup for the
* control.
*/
onRemove (): void;
/**
* Set the style that need to be displayed as currently selected.
* Style will automatically get selected if `StyleControlOptions.autoSelectionMode` is `true`
* @param styleName - Style name that need to be disabled as currently selected
*/
setSelectedStyle (styleName: string): void;
/**
* Set style in a disabled state
* @param styleName Style to be disabled
*/
disableStyle (styleName: string): void;
/**
* Enabled style that was previously disabled
* @param styleName Style to be disabled
*/
enableStyle (styleName: string): void;
private buildSelectStyleBtn;
private buildCurrStyleBtn;
private buildStyleOpsGrid;
private setStyleOpsVisible;
/**
* Callback handler for the style changing.
*/
private onStyleChange;
}
/**
* A control for changing the zoom of the map.
*/
export class ZoomControl extends ControlBase {
protected static ZOOM_DURATION_MS: number;
protected container: HTMLDivElement | null;
protected zoomInButton: HTMLButtonElement | null;
protected zoomOutButton: HTMLButtonElement | null;
protected map: Map | null;
protected options: ZoomControlOptions;
/**
* Constructs a ZoomControl.
* @param options The options for the control.
*/
constructor (options?: ZoomControlOptions);
/**
* Initialization method for the control which is called when added to the map.
* @param map The map that the control will be added to.
* @return An HTMLElement to be placed on the map for the control.
*/
onAdd (map: Map): HTMLElement;
onRemove (): void;
protected zoomChanged: (event: MapEvent) => void;
protected minZoomChanged: (zoom: number) => void;
protected maxZoomChanged: (zoom: number) => void;
protected updateZoomButtonsState (): void;
protected constructZoomInButton: (map: Map) => HTMLElement;
protected constructZoomOutButton: (map: Map) => HTMLElement;
}
/**
* A control to display the traffic information of the map.
*/
export class TrafficControl extends ControlBase {
private hasMouse;
private hasFocus;
private options;
private initIsActive;
private style;
private container;
private trafficButton;
private map;
/**
* Constructs a TrafficControl
* @param options The options for the control.
*/
constructor (options?: TrafficControlOptions);
/**
* Current control state (is traffic information displayed?)
*/
get isActive (): boolean;
/**
* Sets the control state
*/
set isActive (newValue: boolean);
/**
* Initialization method for the control which is called when added to the map.
* @param map The map that the control will be added to.
* @param options The ControlOptions for this control.
* @return An HTMLElement to be placed on the map for the control.
*/
onAdd (map: Map): HTMLElement;
/**
* Method that is called when the control is removed from the map. Should perform any necessary cleanup for the
* control.
*/
onRemove (): void;
/**
* Updates the button state according to current traffic state
*/
updateButtonState (): void;
/**
* Get the TrafficControlOptions
*/
getOptions (): TrafficControlOptions;
private constructTrafficButton;
}
/**
* A control that display traffic legend on the map.
*/
export class TrafficLegendControl extends ControlBase {
private table;
/**
* Construct a traffic legend control
*/
constructor ();
/**
* Initialization method for the control which is called when added to the map.
* @param map The map that the control will be added to.
* @param options The ControlOptions for this control.
* @return An HTMLElement to be placed on the map for the control.
*/
onAdd (map: Map): HTMLElement;
private buildTrafficLegendDiv;
}
/**
* A control to make the map or a specified element fullscreen.
*/
export class FullscreenControl extends ControlBase {
private map: Map | null;
private options: FullscreenControlOptions;
private control;
private isFullscreenState: boolean;
/**
* A control to make the map or a specified element fullscreen.
* @param options Options for defining how the control is rendered and the container to be made fullscreen.
*/
constructor (options?: FullscreenControlOptions);
/**
* Initialization method for the control which is called when added to the map.
* @param map The map that the control will be added to.
* @param options The ControlOptions for this control.
* @return An HTMLElement to be placed on the map for the control.
*/
onAdd (map: Map): HTMLElement;
/**
* Method that is called when the control is removed from the map. Should perform any necessary cleanup for the control.
*/
onRemove (): void;
/**
* Gets the current fullscreen state of the map.
* @returns A boolean indicating if the container is in fullscreen mode.
*/
isFullscreen (): boolean;
/**
* Checks to see if the browser supports going into fullscreen mode.
* @returns A boolean indicating if the browser supports fullscreen mode.
*/
static isSupported (): boolean;
}
}
//internal classes
export module internal {
export interface EventArgs {
[key: string]: any;
}
/**
* An internal abstract class that can be extended to provide event listening/firing.
* This class is for internal use only, and users will find little use with it.
* Not to be used by the Map class. MapCallbackHandler implements the more complex logic for handling map events.
*/
export abstract class EventEmitter<T extends EventArgs> {
private readonly listeners;
/**
* Adds an event listener.
* @param eventType The event name.
* @param callback The event handler callback.
*/
_addEventListener<K extends keyof T>(eventType: K, callback: (e: T[K]) => void, once: boolean): void;
_addEventListener (eventType: string, callback: (e: T[string]) => void, once: boolean): void;
/**
* Removes an event listener.
* @param eventType The event name.
* @param callback The event handler callback.
*/
_removeEventListener<K extends keyof T>(eventType: K, callback: (e: T[K]) => void): void;
_removeEventListener (eventType: string, callback: (e: T[string]) => void): void;
/**
* Invokes a given event type.
* @param eventType The event name.
* @param eventData The data to pass to the listener callbacks.
*/
_invokeEvent<K extends keyof T>(eventType: K, eventData: T[K]): void;
}
}
//layer classes
export module layer {
/**
* Renders Point objects as scalable circles (bubbles).
*/
export class BubbleLayer extends Layer {
/**
* Constructs a new BubbleLayer.
* @param source The id or instance of a data source which the layer will render.
* @param id The id of the layer. If not specified a random one will be generated.
* @param options The options of the bubble layer.
*/
constructor (source: string | atlas.source.Source, id?: string, options?: BubbleLayerOptions);
/**
* Gets the options of the bubble layer.
*/
getOptions (): BubbleLayerOptions;
/**
* Gets the source provided when creating the layer.
*/
getSource (): string | atlas.source.Source;
/**
* Sets the options of the bubble layer.
* @param newOptions The new options of the bubble layer.
*/
setOptions (options: BubbleLayerOptions): void;
}
export interface LayerEvents {
layeradded: Layer;
layerremoved: Layer;
}
/**
* Abstract class for other layer classes to extend.
*/
export abstract class Layer<T extends LayerEvents = LayerEvents> extends atlas.internal.EventEmitter<T> {
protected readonly id: string;
protected map: Map;
private static readonly LayerEvents;
/**
* A property for associating custom data with the layer.
*/
metadata?: any;
constructor (id?: string);
/**
* Gets the id of the layer
*/
getId (): string;
/**
* Gets the map that the layer is currently added to, or null.
*/
getMap (): Map;
/**
* Initialization method for the layer which is called when added to the map.
* @param map The map the layer has been added to.
*/
onAdd (map: Map): void;
/**
* Method that is called when the layer is removed from the map.
* Should perform any necessary cleanup for the layer.
*/
onRemove (): void;
/**
* Gets the options of the layer.
*/
abstract getOptions (): LayerOptions;
/**
* Sets the options of the layer.
* @param options The new options of the layer.
*/
abstract setOptions (options: LayerOptions): void;
}
/**
* Represent the density of data using different colors (HeatMap).
*/
export class HeatMapLayer extends Layer {
/**
* Constructs a new HeatMapLayer..
* @param source The id or instance of a data source which the layer will render.
* @param id The id of the layer. If not specified a random one will be generated.
* @param options The options of the line layer.
*/
constructor (source: string | atlas.source.Source, id?: string, options?: HeatMapLayerOptions);
/**
* Gets the options of the heat map layer.
*/
getOptions (): HeatMapLayerOptions;
/**
* Gets the source provided when creating the layer.
*/
getSource (): string | atlas.source.Source;
/**
* Sets the options of the heat map layer.
* @param newOptions The new options of the heat map layer.
*/
setOptions (options: HeatMapLayerOptions): void;
}
/**
* Overlays an image on the map with each corner anchored to a coordinate on the map. Also known as a ground or image overlay.
*/
export class ImageLayer extends Layer {
/**
* Constructs a new ImageLayer.
* @param options The options for the tile layer.
* @param id The id of the layer. If not specified a random one will be generated.
*/
constructor (options: ImageLayerOptions, id?: string);
/**
* Gets the options of the tile layer.
*/
getOptions (): ImageLayerOptions;
/**
* Sets the options of the tile layer.
* @param newOptions The new options of the tile layer.
*/
setOptions (options: ImageLayerOptions): void;
/**
* Calculates the approximate positions that align with the provided pixels from the source image.
* @param pixels the provided pixels from the source image used to calculate the positions
*/
getPositions (pixels: Pixel[]): Promise<atlas.data.Position[]>;
/**
* Calculates the approximate pixels on the source image that align with the provided positions.
* @param positions the provided positions from the source image used to calculate the pixels
*/
getPixels (positions: atlas.data.Position[]): Promise<Pixel[]>;
/**
* Calculates coordinates for a rotated image layer when provided with the bounding box edges and rotation value.
* Note: If your rotation value is from a KML Ground Overlay it will need to be converted to a clockwise rotation using the following formula: `rotation = 360 – KmlRotation`
* @param north The north edge of the bounding box.
* @param south The south edge of the bounding box.
* @param east The east edge of the bounding box.
* @param west The west edge of the bounding box.
* @param rotation Clockwise rotation in degrees
*/
static getCoordinatesFromEdges (north: number, south: number, east: number, west: number, rotation?: number): atlas.data.Position[];
/**
* Calculates coordinates for a rotated image layer when provided with the bounding box edges and rotation value.
* Note: If your rotation value is from a KML Ground Overlay it will need to be converted to a clockwise rotation using the following formula: `rotation = 360 – KmlRotation`
* @param north The north edge of the bounding box.
* @param south The south edge of the bounding box.
* @param east The east edge of the bounding box.
* @param west The west edge of the bounding box.
* @param rotation Clockwise rotation in degrees
*/
static getCoordinatesFromEdges (north: number, south: number, east: number, west: number, rotation?: number): atlas.data.Position[];
}
/**
* Ren