UNPKG

maplibre-gl

Version:

BSD licensed community fork of mapbox-gl, a WebGL interactive maps library

1,345 lines (1,343 loc) 472 kB
// Generated by dts-bundle-generator v9.5.1 import Point from '@mapbox/point-geometry'; import TinySDF from '@mapbox/tiny-sdf'; import { VectorTileFeature, VectorTileLayer } from '@mapbox/vector-tile'; import { Color, CompositeExpression, DiffCommand, DiffOperations, Feature, FeatureFilter, FeatureState, FilterSpecification, Formatted, FormattedSection, GeoJSONSourceSpecification, GlobalProperties, ICanonicalTileID, IMercatorCoordinate, ImageSourceSpecification, InterpolationType, LayerSpecification, LightSpecification, Padding, PromoteIdSpecification, PropertyValueSpecification, RasterDEMSourceSpecification, RasterSourceSpecification, ResolvedImage, SkySpecification, SourceExpression, SourceSpecification, SpriteSpecification, StylePropertyExpression, StylePropertySpecification, StyleSpecification, TerrainSpecification, TransitionSpecification, VariableAnchorOffsetCollection, VectorSourceSpecification, VideoSourceSpecification } from '@maplibre/maplibre-gl-style-spec'; import { Options as GeoJSONVTOptions } from 'geojson-vt'; import { mat2, mat4, vec4 } from 'gl-matrix'; import KDBush from 'kdbush'; import { PotpackBox } from 'potpack'; import { ClusterProperties, Options as SuperclusterOptions } from 'supercluster'; /** * A type used to store the tile's expiration date and cache control definition */ export type ExpiryData = { cacheControl?: string | null; expires?: Date | string | null; }; /** * A `RequestParameters` object to be returned from Map.options.transformRequest callbacks. * @example * ```ts * // use transformRequest to modify requests that begin with `http://myHost` * transformRequest: function(url, resourceType) { * if (resourceType === 'Source' && url.indexOf('http://myHost') > -1) { * return { * url: url.replace('http', 'https'), * headers: { 'my-custom-header': true }, * credentials: 'include' // Include cookies for cross-origin requests * } * } * } * ``` */ export type RequestParameters = { /** * The URL to be requested. */ url: string; /** * The headers to be sent with the request. */ headers?: any; /** * Request method `'GET' | 'POST' | 'PUT'`. */ method?: "GET" | "POST" | "PUT"; /** * Request body. */ body?: string; /** * Response body type to be returned. */ type?: "string" | "json" | "arrayBuffer" | "image"; /** * `'same-origin'|'include'` Use 'include' to send cookies with cross-origin requests. */ credentials?: "same-origin" | "include"; /** * If `true`, Resource Timing API information will be collected for these transformed requests and returned in a resourceTiming property of relevant data events. */ collectResourceTiming?: boolean; /** * Parameters supported only by browser fetch API. Property of the Request interface contains the cache mode of the request. It controls how the request will interact with the browser's HTTP cache. (https://developer.mozilla.org/en-US/docs/Web/API/Request/cache) */ cache?: RequestCache; }; /** * The response object returned from a successful AJAx request */ export type GetResourceResponse<T> = ExpiryData & { data: T; }; /** * An error thrown when a HTTP request results in an error response. */ export declare class AJAXError extends Error { /** * The response's HTTP status code. */ status: number; /** * The response's HTTP status text. */ statusText: string; /** * The request's URL. */ url: string; /** * The response's body. */ body: Blob; /** * @param status - The response's HTTP status code. * @param statusText - The response's HTTP status text. * @param url - The request's URL. * @param body - The response's body. */ constructor(status: number, statusText: string, url: string, body: Blob); } /** * This method type is used to register a protocol handler. * Use the abort controller for aborting requests. * Return a promise with the relevant resource response. */ export type AddProtocolAction = (requestParameters: RequestParameters, abortController: AbortController) => Promise<GetResourceResponse<any>>; /** * This is a global config object used to store the configuration * It is available in the workers as well. * Only serializable data should be stored in it. */ export type Config = { MAX_PARALLEL_IMAGE_REQUESTS: number; MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME: number; MAX_TILE_CACHE_ZOOM_LEVELS: number; REGISTERED_PROTOCOLS: { [x: string]: AddProtocolAction; }; WORKER_URL: string; }; export declare const config: Config; /** * A class that is serialized to and json, that can be constructed back to the original class in the worker or in the main thread */ export type SerializedObject<S extends Serialized = any> = { [_: string]: S; }; /** * All the possible values that can be serialized and sent to and from the worker */ export type Serialized = null | void | boolean | number | string | Boolean | Number | String | Date | RegExp | ArrayBuffer | ArrayBufferView | ImageData | ImageBitmap | Blob | Array<Serialized> | SerializedObject; declare class ThrottledInvoker { _channel: MessageChannel; _triggered: boolean; _methodToThrottle: Function; constructor(methodToThrottle: Function); trigger(): void; remove(): void; } declare const viewTypes: { Int8: Int8ArrayConstructor; Uint8: Uint8ArrayConstructor; Int16: Int16ArrayConstructor; Uint16: Uint16ArrayConstructor; Int32: Int32ArrayConstructor; Uint32: Uint32ArrayConstructor; Float32: Float32ArrayConstructor; }; /** * @internal * A view type size */ export type ViewType = keyof typeof viewTypes; declare class Struct { _pos1: number; _pos2: number; _pos4: number; _pos8: number; readonly _structArray: StructArray; size: number; /** * @param structArray - The StructArray the struct is stored in * @param index - The index of the struct in the StructArray. */ constructor(structArray: StructArray, index: number); } /** * @internal * A struct array member */ export type StructArrayMember = { name: string; type: ViewType; components: number; offset: number; }; /** * An array that can be desialized */ export type SerializedStructArray = { length: number; arrayBuffer: ArrayBuffer; }; declare abstract class StructArray { capacity: number; length: number; isTransferred: boolean; arrayBuffer: ArrayBuffer; uint8: Uint8Array; members: Array<StructArrayMember>; bytesPerElement: number; abstract emplaceBack(...v: number[]): any; abstract emplace(i: number, ...v: number[]): any; constructor(); /** * Serialize a StructArray instance. Serializes both the raw data and the * metadata needed to reconstruct the StructArray base class during * deserialization. */ static serialize(array: StructArray, transferables?: Array<Transferable>): SerializedStructArray; static deserialize(input: SerializedStructArray): any; /** * Resize the array to discard unused capacity. */ _trim(): void; /** * Resets the length of the array to 0 without de-allocating capacity. */ clear(): void; /** * Resize the array. * If `n` is greater than the current length then additional elements with undefined values are added. * If `n` is less than the current length then the array will be reduced to the first `n` elements. * @param n - The new size of the array. */ resize(n: number): void; /** * Indicate a planned increase in size, so that any necessary allocation may * be done once, ahead of time. * @param n - The expected size of the array. */ reserve(n: number): void; /** * Create TypedArray views for the current ArrayBuffer. */ _refreshViews(): void; } declare class StructArrayLayout2i4 extends StructArray { uint8: Uint8Array; int16: Int16Array; _refreshViews(): void; emplaceBack(v0: number, v1: number): number; emplace(i: number, v0: number, v1: number): number; } declare class StructArrayLayout3i6 extends StructArray { uint8: Uint8Array; int16: Int16Array; _refreshViews(): void; emplaceBack(v0: number, v1: number, v2: number): number; emplace(i: number, v0: number, v1: number, v2: number): number; } declare class StructArrayLayout4i8 extends StructArray { uint8: Uint8Array; int16: Int16Array; _refreshViews(): void; emplaceBack(v0: number, v1: number, v2: number, v3: number): number; emplace(i: number, v0: number, v1: number, v2: number, v3: number): number; } declare class StructArrayLayout2i4i12 extends StructArray { uint8: Uint8Array; int16: Int16Array; _refreshViews(): void; emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number): number; emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number): number; } declare class StructArrayLayout2i4ub8 extends StructArray { uint8: Uint8Array; int16: Int16Array; _refreshViews(): void; emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number): number; emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number): number; } declare class StructArrayLayout2f8 extends StructArray { uint8: Uint8Array; float32: Float32Array; _refreshViews(): void; emplaceBack(v0: number, v1: number): number; emplace(i: number, v0: number, v1: number): number; } declare class StructArrayLayout4i4ui4i24 extends StructArray { uint8: Uint8Array; int16: Int16Array; uint16: Uint16Array; _refreshViews(): void; emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number): number; emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number): number; } declare class StructArrayLayout3f12 extends StructArray { uint8: Uint8Array; float32: Float32Array; _refreshViews(): void; emplaceBack(v0: number, v1: number, v2: number): number; emplace(i: number, v0: number, v1: number, v2: number): number; } declare class StructArrayLayout1ul4 extends StructArray { uint8: Uint8Array; uint32: Uint32Array; _refreshViews(): void; emplaceBack(v0: number): number; emplace(i: number, v0: number): number; } declare class StructArrayLayout6i1ul2ui20 extends StructArray { uint8: Uint8Array; int16: Int16Array; uint32: Uint32Array; uint16: Uint16Array; _refreshViews(): void; emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number): number; emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number): number; } declare class StructArrayLayout2ub2f2i16 extends StructArray { uint8: Uint8Array; float32: Float32Array; int16: Int16Array; _refreshViews(): void; emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number): number; emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number): number; } declare class StructArrayLayout3ui6 extends StructArray { uint8: Uint8Array; uint16: Uint16Array; _refreshViews(): void; emplaceBack(v0: number, v1: number, v2: number): number; emplace(i: number, v0: number, v1: number, v2: number): number; } declare class StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48 extends StructArray { uint8: Uint8Array; int16: Int16Array; uint16: Uint16Array; uint32: Uint32Array; float32: Float32Array; _refreshViews(): void; emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number): number; emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number): number; } declare class StructArrayLayout8i15ui1ul2f2ui64 extends StructArray { uint8: Uint8Array; int16: Int16Array; uint16: Uint16Array; uint32: Uint32Array; float32: Float32Array; _refreshViews(): void; emplaceBack(v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number, v17: number, v18: number, v19: number, v20: number, v21: number, v22: number, v23: number, v24: number, v25: number, v26: number, v27: number): number; emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number, v17: number, v18: number, v19: number, v20: number, v21: number, v22: number, v23: number, v24: number, v25: number, v26: number, v27: number): number; } declare class StructArrayLayout1f4 extends StructArray { uint8: Uint8Array; float32: Float32Array; _refreshViews(): void; emplaceBack(v0: number): number; emplace(i: number, v0: number): number; } declare class StructArrayLayout1ui2f12 extends StructArray { uint8: Uint8Array; uint16: Uint16Array; float32: Float32Array; _refreshViews(): void; emplaceBack(v0: number, v1: number, v2: number): number; emplace(i: number, v0: number, v1: number, v2: number): number; } declare class StructArrayLayout1ul2ui8 extends StructArray { uint8: Uint8Array; uint32: Uint32Array; uint16: Uint16Array; _refreshViews(): void; emplaceBack(v0: number, v1: number, v2: number): number; emplace(i: number, v0: number, v1: number, v2: number): number; } declare class StructArrayLayout2ui4 extends StructArray { uint8: Uint8Array; uint16: Uint16Array; _refreshViews(): void; emplaceBack(v0: number, v1: number): number; emplace(i: number, v0: number, v1: number): number; } declare class StructArrayLayout1ui2 extends StructArray { uint8: Uint8Array; uint16: Uint16Array; _refreshViews(): void; emplaceBack(v0: number): number; emplace(i: number, v0: number): number; } declare class CollisionBoxStruct extends Struct { _structArray: CollisionBoxArray; get anchorPointX(): number; get anchorPointY(): number; get x1(): number; get y1(): number; get x2(): number; get y2(): number; get featureIndex(): number; get sourceLayerIndex(): number; get bucketIndex(): number; get anchorPoint(): Point; } declare class CollisionBoxArray extends StructArrayLayout6i1ul2ui20 { /** * Return the CollisionBoxStruct at the given location in the array. * @param index The index of the element. */ get(index: number): CollisionBoxStruct; } declare class PlacedSymbolStruct extends Struct { _structArray: PlacedSymbolArray; get anchorX(): number; get anchorY(): number; get glyphStartIndex(): number; get numGlyphs(): number; get vertexStartIndex(): number; get lineStartIndex(): number; get lineLength(): number; get segment(): number; get lowerSize(): number; get upperSize(): number; get lineOffsetX(): number; get lineOffsetY(): number; get writingMode(): number; get placedOrientation(): number; set placedOrientation(x: number); get hidden(): number; set hidden(x: number); get crossTileID(): number; set crossTileID(x: number); get associatedIconIndex(): number; } declare class PlacedSymbolArray extends StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48 { /** * Return the PlacedSymbolStruct at the given location in the array. * @param index The index of the element. */ get(index: number): PlacedSymbolStruct; } declare class SymbolInstanceStruct extends Struct { _structArray: SymbolInstanceArray; get anchorX(): number; get anchorY(): number; get rightJustifiedTextSymbolIndex(): number; get centerJustifiedTextSymbolIndex(): number; get leftJustifiedTextSymbolIndex(): number; get verticalPlacedTextSymbolIndex(): number; get placedIconSymbolIndex(): number; get verticalPlacedIconSymbolIndex(): number; get key(): number; get textBoxStartIndex(): number; get textBoxEndIndex(): number; get verticalTextBoxStartIndex(): number; get verticalTextBoxEndIndex(): number; get iconBoxStartIndex(): number; get iconBoxEndIndex(): number; get verticalIconBoxStartIndex(): number; get verticalIconBoxEndIndex(): number; get featureIndex(): number; get numHorizontalGlyphVertices(): number; get numVerticalGlyphVertices(): number; get numIconVertices(): number; get numVerticalIconVertices(): number; get useRuntimeCollisionCircles(): number; get crossTileID(): number; set crossTileID(x: number); get textBoxScale(): number; get collisionCircleDiameter(): number; get textAnchorOffsetStartIndex(): number; get textAnchorOffsetEndIndex(): number; } export type SymbolInstance = SymbolInstanceStruct; declare class SymbolInstanceArray extends StructArrayLayout8i15ui1ul2f2ui64 { /** * Return the SymbolInstanceStruct at the given location in the array. * @param index The index of the element. */ get(index: number): SymbolInstanceStruct; } declare class GlyphOffsetArray extends StructArrayLayout1f4 { getoffsetX(index: number): number; } declare class SymbolLineVertexArray extends StructArrayLayout3i6 { getx(index: number): number; gety(index: number): number; gettileUnitDistanceFromAnchor(index: number): number; } declare class TextAnchorOffsetStruct extends Struct { _structArray: TextAnchorOffsetArray; get textAnchor(): number; get textOffset0(): number; get textOffset1(): number; } export type TextAnchorOffset = TextAnchorOffsetStruct; declare class TextAnchorOffsetArray extends StructArrayLayout1ui2f12 { /** * Return the TextAnchorOffsetStruct at the given location in the array. * @param index The index of the element. */ get(index: number): TextAnchorOffsetStruct; } declare class FeatureIndexStruct extends Struct { _structArray: FeatureIndexArray; get featureIndex(): number; get sourceLayerIndex(): number; get bucketIndex(): number; } declare class FeatureIndexArray extends StructArrayLayout1ul2ui8 { /** * Return the FeatureIndexStruct at the given location in the array. * @param index The index of the element. */ get(index: number): FeatureIndexStruct; } declare class PosArray extends StructArrayLayout2i4 { } declare class RasterBoundsArray extends StructArrayLayout4i8 { } declare class CircleLayoutArray extends StructArrayLayout2i4 { } declare class FillLayoutArray extends StructArrayLayout2i4 { } declare class FillExtrusionLayoutArray extends StructArrayLayout2i4i12 { } declare class LineLayoutArray extends StructArrayLayout2i4ub8 { } declare class LineExtLayoutArray extends StructArrayLayout2f8 { } declare class SymbolLayoutArray extends StructArrayLayout4i4ui4i24 { } declare class SymbolDynamicLayoutArray extends StructArrayLayout3f12 { } declare class SymbolOpacityArray extends StructArrayLayout1ul4 { } declare class CollisionVertexArray extends StructArrayLayout2ub2f2i16 { } declare class TriangleIndexArray extends StructArrayLayout3ui6 { } declare class LineIndexArray extends StructArrayLayout2ui4 { } declare class LineStripIndexArray extends StructArrayLayout1ui2 { } /** * A {@link LngLat} object, an array of two numbers representing longitude and latitude, * or an object with `lng` and `lat` or `lon` and `lat` properties. * * @group Geography and Geometry * * @example * ```ts * let v1 = new LngLat(-122.420679, 37.772537); * let v2 = [-122.420679, 37.772537]; * let v3 = {lon: -122.420679, lat: 37.772537}; * ``` */ export type LngLatLike = LngLat | { lng: number; lat: number; } | { lon: number; lat: number; } | [ number, number ]; /** * A `LngLat` object represents a given longitude and latitude coordinate, measured in degrees. * These coordinates are based on the [WGS84 (EPSG:4326) standard](https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84). * * MapLibre GL JS uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match the * [GeoJSON specification](https://tools.ietf.org/html/rfc7946). * * Note that any MapLibre GL JS method that accepts a `LngLat` object as an argument or option * can also accept an `Array` of two numbers and will perform an implicit conversion. * This flexible type is documented as {@link LngLatLike}. * * @group Geography and Geometry * * @example * ```ts * let ll = new LngLat(-123.9749, 40.7736); * ll.lng; // = -123.9749 * ``` * @see [Get coordinates of the mouse pointer](https://maplibre.org/maplibre-gl-js/docs/examples/mouse-position/) * @see [Display a popup](https://maplibre.org/maplibre-gl-js/docs/examples/popup/) * @see [Create a timeline animation](https://maplibre.org/maplibre-gl-js/docs/examples/timeline-animation/) */ export declare class LngLat { lng: number; lat: number; /** * @param lng - Longitude, measured in degrees. * @param lat - Latitude, measured in degrees. */ constructor(lng: number, lat: number); /** * Returns a new `LngLat` object whose longitude is wrapped to the range (-180, 180). * * @returns The wrapped `LngLat` object. * @example * ```ts * let ll = new LngLat(286.0251, 40.7736); * let wrapped = ll.wrap(); * wrapped.lng; // = -73.9749 * ``` */ wrap(): LngLat; /** * Returns the coordinates represented as an array of two numbers. * * @returns The coordinates represented as an array of longitude and latitude. * @example * ```ts * let ll = new LngLat(-73.9749, 40.7736); * ll.toArray(); // = [-73.9749, 40.7736] * ``` */ toArray(): [ number, number ]; /** * Returns the coordinates represent as a string. * * @returns The coordinates represented as a string of the format `'LngLat(lng, lat)'`. * @example * ```ts * let ll = new LngLat(-73.9749, 40.7736); * ll.toString(); // = "LngLat(-73.9749, 40.7736)" * ``` */ toString(): string; /** * Returns the approximate distance between a pair of coordinates in meters * Uses the Haversine Formula (from R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159) * * @param lngLat - coordinates to compute the distance to * @returns Distance in meters between the two coordinates. * @example * ```ts * let new_york = new LngLat(-74.0060, 40.7128); * let los_angeles = new LngLat(-118.2437, 34.0522); * new_york.distanceTo(los_angeles); // = 3935751.690893987, "true distance" using a non-spherical approximation is ~3966km * ``` */ distanceTo(lngLat: LngLat): number; /** * Converts an array of two numbers or an object with `lng` and `lat` or `lon` and `lat` properties * to a `LngLat` object. * * If a `LngLat` object is passed in, the function returns it unchanged. * * @param input - An array of two numbers or object to convert, or a `LngLat` object to return. * @returns A new `LngLat` object, if a conversion occurred, or the original `LngLat` object. * @example * ```ts * let arr = [-73.9749, 40.7736]; * let ll = LngLat.convert(arr); * ll; // = LngLat {lng: -73.9749, lat: 40.7736} * ``` */ static convert(input: LngLatLike): LngLat; } /** * A `MercatorCoordinate` object represents a projected three dimensional position. * * `MercatorCoordinate` 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, `MercatorCoordinate(0, 0, 0)` is the north-west corner of the mercator world and * `MercatorCoordinate(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 `MercatorCoordinate` is conformal. A cube in the mercator coordinate space would be rendered as a cube. * * @group Geography and Geometry * * @example * ```ts * let nullIsland = new MercatorCoordinate(0.5, 0.5, 0); * ``` * @see [Add a custom style layer](https://maplibre.org/maplibre-gl-js/docs/examples/custom-style-layer/) */ export declare class MercatorCoordinate implements IMercatorCoordinate { x: number; y: number; z: number; /** * @param x - The x component of the position. * @param y - The y component of the position. * @param z - The z component of the position. */ constructor(x: number, y: number, z?: number); /** * Project a `LngLat` to a `MercatorCoordinate`. * * @param lngLatLike - The location to project. * @param altitude - The altitude in meters of the position. * @returns The projected mercator coordinate. * @example * ```ts * let coord = MercatorCoordinate.fromLngLat({ lng: 0, lat: 0}, 0); * coord; // MercatorCoordinate(0.5, 0.5, 0) * ``` */ static fromLngLat(lngLatLike: LngLatLike, altitude?: number): MercatorCoordinate; /** * Returns the `LngLat` for the coordinate. * * @returns The `LngLat` object. * @example * ```ts * let coord = new MercatorCoordinate(0.5, 0.5, 0); * let lngLat = coord.toLngLat(); // LngLat(0, 0) * ``` */ toLngLat(): LngLat; /** * Returns the altitude in meters of the coordinate. * * @returns The altitude in meters. * @example * ```ts * let coord = new MercatorCoordinate(0, 0, 0.02); * coord.toAltitude(); // 6914.281956295339 * ``` */ toAltitude(): number; /** * Returns the distance of 1 meter in `MercatorCoordinate` units at this latitude. * * For coordinates in real world units using meters, this naturally provides the scale * to transform into `MercatorCoordinate`s. * * @returns Distance of 1 meter in `MercatorCoordinate` units. */ meterInMercatorCoordinateUnits(): number; } declare class CanonicalTileID implements ICanonicalTileID { z: number; x: number; y: number; key: string; constructor(z: number, x: number, y: number); equals(id: ICanonicalTileID): boolean; url(urls: Array<string>, pixelRatio: number, scheme?: string | null): string; isChildOf(parent: ICanonicalTileID): boolean; getTilePoint(coord: IMercatorCoordinate): Point; toString(): string; } declare class UnwrappedTileID { wrap: number; canonical: CanonicalTileID; key: string; constructor(wrap: number, canonical: CanonicalTileID); } declare class OverscaledTileID { overscaledZ: number; wrap: number; canonical: CanonicalTileID; key: string; posMatrix: mat4; constructor(overscaledZ: number, wrap: number, z: number, x: number, y: number); clone(): OverscaledTileID; equals(id: OverscaledTileID): boolean; scaledTo(targetZ: number): OverscaledTileID; calculateScaledKey(targetZ: number, withWrap: boolean): string; isChildOf(parent: OverscaledTileID): boolean; children(sourceMaxZoom: number): OverscaledTileID[]; isLessThan(rhs: OverscaledTileID): boolean; wrapped(): OverscaledTileID; unwrapTo(wrap: number): OverscaledTileID; overscaleFactor(): number; toUnwrapped(): UnwrappedTileID; toString(): string; getTilePoint(coord: MercatorCoordinate): Point; } /** * A listener method used as a callback to events */ export type Listener = (a: any) => any; export type Listeners = { [_: string]: Array<Listener>; }; declare class Event$1 { readonly type: string; constructor(type: string, data?: any); } /** * Methods mixed in to other classes for event capabilities. * * @group Event Related */ export declare class Evented { _listeners: Listeners; _oneTimeListeners: Listeners; _eventedParent: Evented; _eventedParentData: any | (() => any); /** * Adds a listener to a specified event type. * * @param type - The event type to add a listen for. * @param listener - The function to be called when the event is fired. * The listener function is called with the data object passed to `fire`, * extended with `target` and `type` properties. */ on(type: string, listener: Listener): this; /** * Removes a previously registered event listener. * * @param type - The event type to remove listeners for. * @param listener - The listener function to remove. */ off(type: string, listener: Listener): this; /** * Adds a listener that will be called only once to a specified event type. * * The listener will be called first time the event fires after the listener is registered. * * @param type - The event type to listen for. * @param listener - The function to be called when the event is fired the first time. * @returns `this` or a promise if a listener is not provided */ once(type: string, listener?: Listener): this | Promise<any>; fire(event: Event$1 | string, properties?: any): this; /** * Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type. * * @param type - The event type * @returns `true` if there is at least one registered listener for specified event type, `false` otherwise */ listens(type: string): boolean; /** * Bubble all events fired by this instance of Evented to this parent instance of Evented. */ setEventedParent(parent?: Evented | null, data?: any | (() => any)): this; } declare class ZoomHistory { lastZoom: number; lastFloorZoom: number; lastIntegerZoom: number; lastIntegerZoomTime: number; first: boolean; constructor(); update(z: number, now: number): boolean; } export type CrossfadeParameters = { fromScale: number; toScale: number; t: number; }; declare class EvaluationParameters { zoom: number; now: number; fadeDuration: number; zoomHistory: ZoomHistory; transition: TransitionSpecification; constructor(zoom: number, options?: any); isSupportedScript(str: string): boolean; crossFadingFactor(): number; getCrossfadeParameters(): CrossfadeParameters; } export type TimePoint = number; /** * A from-to type */ export type CrossFaded<T> = { to: T; from: T; }; /** * @internal * Implementations of the `Property` interface: * * * Hold metadata about a property that's independent of any specific value: stuff like the type of the value, * the default value, etc. This comes from the style specification JSON. * * Define behavior that needs to be polymorphic across different properties: "possibly evaluating" * an input value (see below), and interpolating between two possibly-evaluted values. * * The type `T` is the fully-evaluated value type (e.g. `number`, `string`, `Color`). * The type `R` is the intermediate "possibly evaluated" value type. See below. * * There are two main implementations of the interface -- one for properties that allow data-driven values, * and one for properties that don't. There are a few "special case" implementations as well: one for properties * which cross-fade between two values rather than interpolating, one for `heatmap-color` and `line-gradient`, * and one for `light-position`. */ export interface Property<T, R> { specification: StylePropertySpecification; possiblyEvaluate(value: PropertyValue<T, R>, parameters: EvaluationParameters, canonical?: CanonicalTileID, availableImages?: Array<string>): R; interpolate(a: R, b: R, t: number): R; } declare class PropertyValue<T, R> { property: Property<T, R>; value: PropertyValueSpecification<T> | void; expression: StylePropertyExpression; constructor(property: Property<T, R>, value: PropertyValueSpecification<T> | void); isDataDriven(): boolean; possiblyEvaluate(parameters: EvaluationParameters, canonical?: CanonicalTileID, availableImages?: Array<string>): R; } export type TransitionParameters = { now: TimePoint; transition: TransitionSpecification; }; declare class TransitionablePropertyValue<T, R> { property: Property<T, R>; value: PropertyValue<T, R>; transition: TransitionSpecification | void; constructor(property: Property<T, R>); transitioned(parameters: TransitionParameters, prior: TransitioningPropertyValue<T, R>): TransitioningPropertyValue<T, R>; untransitioned(): TransitioningPropertyValue<T, R>; } declare class Transitionable<Props> { _properties: Properties<Props>; _values: { [K in keyof Props]: TransitionablePropertyValue<any, unknown>; }; constructor(properties: Properties<Props>); getValue<S extends keyof Props, T>(name: S): PropertyValueSpecification<T> | void; setValue<S extends keyof Props, T>(name: S, value: PropertyValueSpecification<T> | void): void; getTransition<S extends keyof Props>(name: S): TransitionSpecification | void; setTransition<S extends keyof Props>(name: S, value: TransitionSpecification | void): void; serialize(): any; transitioned(parameters: TransitionParameters, prior: Transitioning<Props>): Transitioning<Props>; untransitioned(): Transitioning<Props>; } declare class TransitioningPropertyValue<T, R> { property: Property<T, R>; value: PropertyValue<T, R>; prior: TransitioningPropertyValue<T, R>; begin: TimePoint; end: TimePoint; constructor(property: Property<T, R>, value: PropertyValue<T, R>, prior: TransitioningPropertyValue<T, R>, transition: TransitionSpecification, now: TimePoint); possiblyEvaluate(parameters: EvaluationParameters, canonical: CanonicalTileID, availableImages: Array<string>): R; } declare class Transitioning<Props> { _properties: Properties<Props>; _values: { [K in keyof Props]: PossiblyEvaluatedPropertyValue<unknown>; }; constructor(properties: Properties<Props>); possiblyEvaluate(parameters: EvaluationParameters, canonical?: CanonicalTileID, availableImages?: Array<string>): PossiblyEvaluated<Props, any>; hasTransition(): boolean; } declare class Layout<Props> { _properties: Properties<Props>; _values: { [K in keyof Props]: PropertyValue<any, PossiblyEvaluatedPropertyValue<any>>; }; constructor(properties: Properties<Props>); hasValue<S extends keyof Props>(name: S): boolean; getValue<S extends keyof Props>(name: S): any; setValue<S extends keyof Props>(name: S, value: any): void; serialize(): any; possiblyEvaluate(parameters: EvaluationParameters, canonical?: CanonicalTileID, availableImages?: Array<string>): PossiblyEvaluated<Props, any>; } /** * "Possibly evaluated value" is an intermediate stage in the evaluation chain for both paint and layout property * values. The purpose of this stage is to optimize away unnecessary recalculations for data-driven properties. Code * which uses data-driven property values must assume that the value is dependent on feature data, and request that it * be evaluated for each feature. But when that property value is in fact a constant or camera function, the calculation * will not actually depend on the feature, and we can benefit from returning the prior result of having done the * evaluation once, ahead of time, in an intermediate step whose inputs are just the value and "global" parameters * such as current zoom level. * * `PossiblyEvaluatedValue` represents the three possible outcomes of this step: if the input value was a constant or * camera expression, then the "possibly evaluated" result is a constant value. Otherwise, the input value was either * a source or composite expression, and we must defer final evaluation until supplied a feature. We separate * the source and composite cases because they are handled differently when generating GL attributes, buffers, and * uniforms. * * Note that `PossiblyEvaluatedValue` (and `PossiblyEvaluatedPropertyValue`, below) are _not_ used for properties that * do not allow data-driven values. For such properties, we know that the "possibly evaluated" result is always a constant * scalar value. See below. */ export type PossiblyEvaluatedValue<T> = { kind: "constant"; value: T; } | SourceExpression | CompositeExpression; declare class PossiblyEvaluatedPropertyValue<T> { property: DataDrivenProperty<T>; value: PossiblyEvaluatedValue<T>; parameters: EvaluationParameters; constructor(property: DataDrivenProperty<T>, value: PossiblyEvaluatedValue<T>, parameters: EvaluationParameters); isConstant(): boolean; constantOr(value: T): T; evaluate(feature: Feature, featureState: FeatureState, canonical?: CanonicalTileID, availableImages?: Array<string>): T; } declare class PossiblyEvaluated<Props, PossibleEvaluatedProps> { _properties: Properties<Props>; _values: PossibleEvaluatedProps; constructor(properties: Properties<Props>); get<S extends keyof PossibleEvaluatedProps>(name: S): PossibleEvaluatedProps[S]; } declare class DataConstantProperty<T> implements Property<T, T> { specification: StylePropertySpecification; constructor(specification: StylePropertySpecification); possiblyEvaluate(value: PropertyValue<T, T>, parameters: EvaluationParameters): T; interpolate(a: T, b: T, t: number): T; } declare class DataDrivenProperty<T> implements Property<T, PossiblyEvaluatedPropertyValue<T>> { specification: StylePropertySpecification; overrides: any; constructor(specification: StylePropertySpecification, overrides?: any); possiblyEvaluate(value: PropertyValue<T, PossiblyEvaluatedPropertyValue<T>>, parameters: EvaluationParameters, canonical?: CanonicalTileID, availableImages?: Array<string>): PossiblyEvaluatedPropertyValue<T>; interpolate(a: PossiblyEvaluatedPropertyValue<T>, b: PossiblyEvaluatedPropertyValue<T>, t: number): PossiblyEvaluatedPropertyValue<T>; evaluate(value: PossiblyEvaluatedValue<T>, parameters: EvaluationParameters, feature: Feature, featureState: FeatureState, canonical?: CanonicalTileID, availableImages?: Array<string>): T; } declare class CrossFadedDataDrivenProperty<T> extends DataDrivenProperty<CrossFaded<T>> { possiblyEvaluate(value: PropertyValue<CrossFaded<T>, PossiblyEvaluatedPropertyValue<CrossFaded<T>>>, parameters: EvaluationParameters, canonical?: CanonicalTileID, availableImages?: Array<string>): PossiblyEvaluatedPropertyValue<CrossFaded<T>>; evaluate(value: PossiblyEvaluatedValue<CrossFaded<T>>, globals: EvaluationParameters, feature: Feature, featureState: FeatureState, canonical?: CanonicalTileID, availableImages?: Array<string>): CrossFaded<T>; _calculate(min: T, mid: T, max: T, parameters: EvaluationParameters): CrossFaded<T>; interpolate(a: PossiblyEvaluatedPropertyValue<CrossFaded<T>>): PossiblyEvaluatedPropertyValue<CrossFaded<T>>; } declare class CrossFadedProperty<T> implements Property<T, CrossFaded<T>> { specification: StylePropertySpecification; constructor(specification: StylePropertySpecification); possiblyEvaluate(value: PropertyValue<T, CrossFaded<T>>, parameters: EvaluationParameters, canonical?: CanonicalTileID, availableImages?: Array<string>): CrossFaded<T>; _calculate(min: T, mid: T, max: T, parameters: EvaluationParameters): CrossFaded<T>; interpolate(a?: CrossFaded<T> | null): CrossFaded<T>; } declare class ColorRampProperty implements Property<Color, boolean> { specification: StylePropertySpecification; constructor(specification: StylePropertySpecification); possiblyEvaluate(value: PropertyValue<Color, boolean>, parameters: EvaluationParameters, canonical?: CanonicalTileID, availableImages?: Array<string>): boolean; interpolate(): boolean; } declare class Properties<Props> { properties: Props; defaultPropertyValues: { [K in keyof Props]: PropertyValue<unknown, any>; }; defaultTransitionablePropertyValues: { [K in keyof Props]: TransitionablePropertyValue<unknown, unknown>; }; defaultTransitioningPropertyValues: { [K in keyof Props]: TransitioningPropertyValue<unknown, unknown>; }; defaultPossiblyEvaluatedValues: { [K in keyof Props]: PossiblyEvaluatedPropertyValue<unknown>; }; overridableProperties: Array<string>; constructor(properties: Props); } export type Size = { width: number; height: number; }; export type Point2D = { x: number; y: number; }; declare class AlphaImage { width: number; height: number; data: Uint8Array; constructor(size: Size, data?: Uint8Array | Uint8ClampedArray); resize(size: Size): void; clone(): AlphaImage; static copy(srcImg: AlphaImage, dstImg: AlphaImage, srcPt: Point2D, dstPt: Point2D, size: Size): void; } declare class RGBAImage { width: number; height: number; /** * data must be a Uint8Array instead of Uint8ClampedArray because texImage2D does not support Uint8ClampedArray in all browsers. */ data: Uint8Array; constructor(size: Size, data?: Uint8Array | Uint8ClampedArray); resize(size: Size): void; replace(data: Uint8Array | Uint8ClampedArray, copy?: boolean): void; clone(): RGBAImage; static copy(srcImg: RGBAImage | ImageData, dstImg: RGBAImage, srcPt: Point2D, dstPt: Point2D, size: Size): void; } /** * The sprite data */ export type SpriteOnDemandStyleImage = { width: number; height: number; x: number; y: number; context: CanvasRenderingContext2D; }; /** * The style's image metadata */ export type StyleImageData = { data: RGBAImage; version?: number; hasRenderCallback?: boolean; userImage?: StyleImageInterface; spriteData?: SpriteOnDemandStyleImage; }; /** * Enumeration of possible values for StyleImageMetadata.textFitWidth and textFitHeight. */ export declare const enum TextFit { /** * The image will be resized on the specified axis to tightly fit the content rectangle to target text. * This is the same as not being defined. */ stretchOrShrink = "stretchOrShrink", /** * The image will be resized on the specified axis to fit the content rectangle to the target text, but will not * fall below the aspect ratio of the original content rectangle if the other axis is set to proportional. */ stretchOnly = "stretchOnly", /** * The image will be resized on the specified axis to fit the content rectangle to the target text and * will resize the other axis to maintain the aspect ratio of the content rectangle. */ proportional = "proportional" } /** * The style's image metadata */ export type StyleImageMetadata = { /** * The ratio of pixels in the image to physical pixels on the screen */ pixelRatio: number; /** * Whether the image should be interpreted as an SDF image */ sdf: boolean; /** * If `icon-text-fit` is used in a layer with this image, this option defines the part(s) of the image that can be stretched horizontally. */ stretchX?: Array<[ number, number ]>; /** * If `icon-text-fit` is used in a layer with this image, this option defines the part(s) of the image that can be stretched vertically. */ stretchY?: Array<[ number, number ]>; /** * If `icon-text-fit` is used in a layer with this image, this option defines the part of the image that can be covered by the content in `text-field`. */ content?: [ number, number, number, number ]; /** * If `icon-text-fit` is used in a layer with this image, this option defines constraints on the horizontal scaling of the image. */ textFitWidth?: TextFit; /** * If `icon-text-fit` is used in a layer with this image, this option defines constraints on the vertical scaling of the image. */ textFitHeight?: TextFit; }; /** * the style's image, including data and metedata */ export type StyleImage = StyleImageData & StyleImageMetadata; /** * Interface for dynamically generated style images. This is a specification for * implementers to model: it is not an exported method or class. * * Images implementing this interface can be redrawn for every frame. They can be used to animate * icons and patterns or make them respond to user input. Style images can implement a * {@link StyleImageInterface#render} method. The method is called every frame and * can be used to update the image. * * @see [Add an animated icon to the map.](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-animated/) * * @example * ```ts * let flashingSquare = { * width: 64, * height: 64, * data: new Uint8Array(64 * 64 * 4), * * onAdd: function(map) { * this.map = map; * }, * * render: function() { * // keep repainting while the icon is on the map * this.map.triggerRepaint(); * * // alternate between black and white based on the time * let value = Math.round(Date.now() / 1000) % 2 === 0 ? 255 : 0; * * // check if image needs to be changed * if (value !== this.previousValue) { * this.previousValue = value; * * let bytesPerPixel = 4; * for (let x = 0; x < this.width; x++) { * for (let y = 0; y < this.height; y++) { * let offset = (y * this.width + x) * bytesPerPixel; * this.data[offset + 0] = value; * this.data[offset + 1] = value; * this.data[offset + 2] = value; * this.data[offset + 3] = 255; * } * } * * // return true to indicate that the image changed * return true; * } * } * } * * map.addImage('flashing_square', flashingSquare); * ``` */ export interface StyleImageInterface { width: number; height: number; data: Uint8Array | Uint8ClampedArray; /** * This method is called once before every frame where the icon will be used. * The method can optionally update the image's `data` member with a new image. * * If the method updates the image it must return `true` to commit the change. * If the method returns `false` or nothing the image is assumed to not have changed. * * If updates are infrequent it maybe easier to use {@link Map#updateImage} to update * the image instead of implementing this method. * * @returns `true` if this method updated the image. `false` if the image was not changed. */ render?: () => boolean; /** * Optional method called when the layer has been added to the Map with {@link Map#addImage}. * * @param map - The Map this custom layer was just added to. */ onAdd?: (map: Map$1, id: string) => void; /** * Optional method called when the icon is removed from the map with {@link Map#removeImage}. * This gives the image a chance to clean up resources and event listeners. */ onRemove?: () => void; } declare class IndexBuffer { context: Context; buffer: WebGLBuffer; dynamicDraw: boolean; constructor(context: Context, array: TriangleIndexArray | LineIndexArray | LineStripIndexArray, dynamicDraw?: boolean); bind(): void; updateData(array: StructArray): void; destroy(): void; } export type SerializedFeaturePositionMap = { ids: Float64Array; positions: Uint32Array; }; export type FeaturePosition = { index: number; start: number; end: number; }; declare class FeaturePositionMap { ids: Array<number>; positions: Array<number>; indexed: boolean; constructor(); add(id: unknown, index: number, start: number, end: number): void; getPositions(id: unknown): Array<FeaturePosition>; static serialize(map: FeaturePositionMap, transferables: Array<ArrayBuffer>): SerializedFeaturePositionMap; static deserialize(obj: SerializedFeaturePositionMap): FeaturePositionMap; } export type $ObjMap<T extends {}, F extends (v: any) => any> = { [K in keyof T]: F extends (v: T[K]) => infer R ? R : never; }; export type UniformValues<Us extends {}> = $ObjMap<Us, <V>(u: Uniform<V>) => V>; export type UniformLocations = { [_: string]: WebGLUniformLocation; }; declare abstract class Uniform<T> { gl: WebGLRenderingContext | WebGL2RenderingContext; location: WebGLUniformLocation; current: T; constructor(context: Context, location: WebGLUniformLocation); abstract set(v: T): void; } declare class Uniform1i extends Uniform<number> { constructor(context: Context, location: WebGLUniformLocation); set(v: number): void; } declare class Uniform1f extends Uniform<number> { constructor(context: Context, location: WebGLUniformLocation); set(v: number): void; } declare class Uniform4f extends Uniform<vec4> { constructor(context: Context, location: WebGLUniformLocation); set(v: vec4): void; } declare class UniformMatrix4f extends Uniform<mat4> { constructor(context: Context, location: WebGLUniformLocation); set(v: mat4): void; } /** * @internal * A uniform bindings */ export type UniformBindings = { [_: string]: Uniform<any>; }; declare class VertexArrayObject { context: Context; boundProgram: Program<any>; boundLayoutVertexBuffer: VertexBuffer; boundPaintVertexBuffers: Array<VertexBuffer>; boundIndexBuffer: IndexBuffer; boundVertexOffset: number; boundDynamicVertexBuffer: VertexBuffer; boundDynamicVertexBuffer2: VertexBuffer; boundDynamicVertexBuffer3: VertexBuffer; vao: any; constructor(); bind(context: Context, program: Program<any>, layoutVertexBuffer: VertexBuffer, paintVertexBuffers: Array<VertexBuffer>, indexBuffer?: IndexBuffer | null, vertexOffset?: number | null, dynamicVertexBuffer?: VertexBuffer | null, dynamicVertexBuffer2?: VertexBuffer | null, dynamicVertexBuffer3?: VertexBuffer | null): void; freshBind(program: Program<any>, layoutVertexBuffer: VertexBuffer, paintVertexBuffers: Array<VertexBuffer>, indexBuffer?: IndexBuffer | null, vertexOffset?: number | null, dynamicVertexBuffer?: VertexBuffer | null, dynamicVertexBuffer2?: VertexBuffer | null, dynamicVertexBuffer3?: VertexBuffer | null): void; destroy(): void; } /** * @internal * A single segment of a vector */ export type Segment = { sortKey?: number; vertexOffset: number; primitiveOffset: number; vertexLength: number; primitiveLength: number; vaos: { [_: string]: VertexArrayObject; }; }; declare class SegmentVector { static MAX_VERTEX_ARRAY_LENGTH: number; segments: Array<Segment>; constructor(segments?: Array<Segment>); prepareSegment(numVertices: number, layoutVertexArray: StructArray, indexArray: StructArray, sortKey?: number): Segment; get(): Segment[]; destroy(): void; static simpleSegment(vertexOffset: number, primitiveOffset: number, vertexLength: number, primitiveLength: number): SegmentVector; } declare class HeatmapBucket extends CircleBucket<HeatmapStyleLayer> { layers: Array<HeatmapStyleLayer>; } export type HeatmapPaintProps = { "heatmap-radius": DataDrivenProperty<number>; "heatmap-weight": DataDrivenProperty<number>; "heatmap-intensity": DataConstantProperty<number>; "heatmap-colo