UNPKG

maplibre-gl

Version:

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

1,443 lines 641 kB
import Point, { default as Point$1 } from "@mapbox/point-geometry"; import { GeoJSONVTOptions } from "@maplibre/geojson-vt"; import { AllLayoutProperties, AllPaintProperties, Color, ColorArray, CompositeExpression, DiffCommand, DiffOperations, Feature, FeatureFilter, FeatureState, FilterSpecification, Formatted, FormattedSection, GeoJSONSourceSpecification, GlobalProperties, ICanonicalTileID, IMercatorCoordinate, ImageSourceSpecification, InterpolationType, LayerSpecification, LightSpecification, NumberArray, Padding, ProjectionSpecification, PromoteIdSpecification, PropertyValueSpecification, RasterDEMSourceSpecification, RasterSourceSpecification, ResolvedImage, SkySpecification, SourceExpression, SourceSpecification, SpriteSpecification, StateSpecification, StylePropertyExpression, StylePropertySpecification, StyleSpecification, TerrainSpecification, TransitionSpecification, ValidationError, VariableAnchorOffsetCollection, VectorSourceSpecification, VideoSourceSpecification, VisibilityExpression, VisibilitySpecification } from "@maplibre/maplibre-gl-style-spec"; import { VectorTileFeatureLike, VectorTileLayerLike } from "@maplibre/vt-pbf"; import { mat2, mat4, vec3, vec4 } from "gl-matrix"; import { PotpackBox } from "potpack"; import KDBush from "kdbush"; import TinySDF from "@mapbox/tiny-sdf"; export type * from "@maplibre/maplibre-gl-style-spec"; //#region src/util/ajax.d.ts /** * A type used to store the tile's expiration date and cache control definition */ type ExpiryData = { cacheControl?: string | null; expires?: Date | string | null; etag?: string; }; /** * 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 * } * } * } * ``` */ 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 referrer policy to use for the request. Controls how much referrer information is sent. (https://developer.mozilla.org/en-US/docs/Web/API/Request/referrerPolicy) */ referrerPolicy?: ReferrerPolicy; }; /** * The response object returned from a successful AJAx request */ type GetResourceResponse<T> = ExpiryData & { data: T; }; /** * An error thrown when a HTTP request results in an error response. */ 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); } //#endregion //#region src/util/config.d.ts /** * 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. */ 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. */ 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; }; declare const config: Config; //#endregion //#region src/util/web_worker_transfer.d.ts /** * 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 */ type SerializedObject<S extends Serialized = any> = { [_: string]: S; }; /** * All the possible values that can be serialized and sent to and from the worker */ type Serialized = null | void | boolean | number | string | Boolean | Number | String | Date | RegExp | ArrayBuffer | ArrayBufferView | ImageData | ImageBitmap | Blob | Serialized[] | SerializedObject; //#endregion //#region src/util/throttled_invoker.d.ts /** * Invokes the wrapped function in a non-blocking way when trigger() is called. * Invocation requests are ignored until the function was actually invoked. */ declare class ThrottledInvoker { _channel: MessageChannel | undefined; _triggered: boolean; _methodToThrottle: Function; constructor(methodToThrottle: Function); trigger(): void; remove(): void; } //#endregion //#region src/util/struct_array.d.ts /** * @internal * A view type size */ declare const viewTypes: { Int8: Int8ArrayConstructor; Uint8: Uint8ArrayConstructor; Int16: Int16ArrayConstructor; Uint16: Uint16ArrayConstructor; Int32: Int32ArrayConstructor; Uint32: Uint32ArrayConstructor; Float32: Float32ArrayConstructor; }; /** * @internal * A view type size */ type ViewType = keyof typeof viewTypes; /** @internal */ 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 */ type StructArrayMember = { name: string; type: ViewType; components: number; offset: number; }; /** * An array that can be deserialized */ type SerializedStructArray = { length: number; arrayBuffer: ArrayBuffer; }; /** * @internal * `StructArray` provides an abstraction over `ArrayBuffer` and `TypedArray` * making it behave like an array of typed structs. * * Conceptually, a StructArray is comprised of elements, i.e., instances of its * associated struct type. Each particular struct type, together with an * alignment size, determines the memory layout of a StructArray whose elements * are of that type. Thus, for each such layout that we need, we have * a corresponding StructArrayLayout class, inheriting from StructArray and * implementing `emplaceBack()` and `_refreshViews()`. * * In some cases, where we need to access particular elements of a StructArray, * we implement a more specific subclass that inherits from one of the * StructArrayLayouts and adds a `get(i): T` accessor that returns a structured * object whose properties are proxies into the underlying memory space for the * i-th element. This affords the convenience of working with (seemingly) plain * Javascript objects without the overhead of serializing/deserializing them * into ArrayBuffers for efficient web worker transfer. */ declare abstract class StructArray { capacity: number; length: number; isTransferred: boolean; arrayBuffer: ArrayBuffer; uint8: Uint8Array; members: StructArrayMember[]; bytesPerElement: number; abstract emplaceBack(...v: number[]): number; abstract emplace(i: number, ...v: number[]): number; 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?: Transferable[]): SerializedStructArray; static deserialize<T extends StructArray>(this: { prototype: T; } & (new () => T), input: SerializedStructArray): T; /** * 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; /** * Replace the buffer with an empty one so typed views release the original ArrayBuffer for GC. */ freeBufferAfterUpload(): void; } //#endregion //#region src/data/array_types.g.d.ts /** * @internal * Implementation of the StructArray layout: * [0] - Int16[2] * */ 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; } /** * @internal * Implementation of the StructArray layout: * [0] - Int16[3] * */ 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; } /** * @internal * Implementation of the StructArray layout: * [0] - Int16[2] * [4] - Int16[4] * */ 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; } /** * @internal * Implementation of the StructArray layout: * [0] - Int16[2] * [4] - Uint8[4] * */ 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; } /** * @internal * Implementation of the StructArray layout: * [0] - Float32[2] * */ 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; } /** * @internal * Implementation of the StructArray layout: * [0] - Int16[4] * [8] - Uint16[4] * [16] - Int16[4] * */ 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; } /** * @internal * Implementation of the StructArray layout: * [0] - Float32[3] * */ 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; } /** * @internal * Implementation of the StructArray layout: * [0] - Uint32[1] * */ declare class StructArrayLayout1ul4 extends StructArray { uint8: Uint8Array; uint32: Uint32Array; _refreshViews(): void; emplaceBack(v0: number): number; emplace(i: number, v0: number): number; } /** * @internal * Implementation of the StructArray layout: * [0] - Int16[6] * [12] - Uint32[1] * [16] - Uint16[2] * */ 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; } /** * @internal * Implementation of the StructArray layout: * [0] - Uint8[2] * [4] - Float32[2] * [12] - Int16[2] * */ 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; } /** * @internal * Implementation of the StructArray layout: * [0] - Uint16[3] * */ 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; } /** * @internal * Implementation of the StructArray layout: * [0] - Int16[2] * [4] - Uint16[2] * [8] - Uint32[3] * [20] - Uint16[3] * [28] - Float32[2] * [36] - Uint8[3] * [40] - Uint32[1] * [44] - Int16[1] * */ 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; } /** * @internal * Implementation of the StructArray layout: * [0] - Int16[8] * [16] - Uint16[15] * [48] - Uint32[1] * [52] - Float32[2] * [60] - Uint16[2] * */ 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; } /** * @internal * Implementation of the StructArray layout: * [0] - Float32[1] * */ declare class StructArrayLayout1f4 extends StructArray { uint8: Uint8Array; float32: Float32Array; _refreshViews(): void; emplaceBack(v0: number): number; emplace(i: number, v0: number): number; } /** * @internal * Implementation of the StructArray layout: * [0] - Uint16[1] * [4] - Float32[2] * */ 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; } /** * @internal * Implementation of the StructArray layout: * [0] - Uint32[1] * [4] - Uint16[2] * */ 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; } /** * @internal * Implementation of the StructArray layout: * [0] - Uint16[2] * */ 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; } /** * @internal * Implementation of the StructArray layout: * [0] - Uint16[1] * */ declare class StructArrayLayout1ui2 extends StructArray { uint8: Uint8Array; uint16: Uint16Array; _refreshViews(): void; emplaceBack(v0: number): number; emplace(i: number, v0: number): number; } /** @internal */ 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$1; } /** @internal */ 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; } /** @internal */ 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; } type PlacedSymbol = PlacedSymbolStruct; /** @internal */ 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; } /** @internal */ 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; } type SymbolInstance = SymbolInstanceStruct; /** @internal */ 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; } /** @internal */ declare class GlyphOffsetArray extends StructArrayLayout1f4 { getoffsetX(index: number): number; } /** @internal */ declare class SymbolLineVertexArray extends StructArrayLayout3i6 { getx(index: number): number; gety(index: number): number; gettileUnitDistanceFromAnchor(index: number): number; } /** @internal */ declare class TextAnchorOffsetStruct extends Struct { _structArray: TextAnchorOffsetArray; get textAnchor(): number; get textOffset0(): number; get textOffset1(): number; } type TextAnchorOffset = TextAnchorOffsetStruct; /** @internal */ 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; } /** @internal */ declare class FeatureIndexStruct extends Struct { _structArray: FeatureIndexArray; get featureIndex(): number; get sourceLayerIndex(): number; get bucketIndex(): number; } /** @internal */ 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 Pos3dArray extends StructArrayLayout3i6 {} 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 {} //#endregion //#region src/geo/lng_lat.d.ts /** * 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}; * ``` */ 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/get-coordinates-of-the-mouse-pointer/) */ declare class LngLat { /** * Longitude, measured in degrees. */ lng: number; /** * Latitude, measured in degrees. */ 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; } //#endregion //#region src/geo/mercator_coordinate.d.ts /** * 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/add-a-custom-style-layer/) * @see [Add a 3D model using three.js](https://maplibre.org/maplibre-gl-js/docs/examples/add-a-3d-model-using-threejs/) * @see [Add a simple custom layer on a globe](https://maplibre.org/maplibre-gl-js/docs/examples/add-a-simple-custom-layer-on-a-globe/) */ 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; } //#endregion //#region src/tile/tile_id.d.ts /** * A canonical way to define a tile ID */ declare class CanonicalTileID implements ICanonicalTileID { z: number; x: number; y: number; key: string; constructor(z: number, x: number, y: number); equals(id: ICanonicalTileID): boolean; /** * given a list of urls, choose a url template and return a tile URL */ url(urls: string[], pixelRatio: number, scheme?: string | null): string; isChildOf(parent: ICanonicalTileID): boolean; getTilePoint(coord: IMercatorCoordinate): Point$1; toString(): string; } /** * @internal * An unwrapped tile identifier */ declare class UnwrappedTileID { wrap: number; canonical: CanonicalTileID; key: string; constructor(wrap: number, canonical: CanonicalTileID); } /** * An overscaled tile identifier */ declare class OverscaledTileID { overscaledZ: number; wrap: number; canonical: CanonicalTileID; key: string; /** * This matrix is used during terrain's render-to-texture stage only. * If the render-to-texture stage is active, this matrix will be present * and should be used, otherwise this matrix will be null. * The matrix should be float32 in order to avoid slow WebGL calls in Chrome. */ terrainRttPosMatrix32f: Mat4f32 | null; constructor(overscaledZ: number, wrap: number, z: number, x: number, y: number); clone(): OverscaledTileID; equals(id: OverscaledTileID): boolean; /** * Returns a new `OverscaledTileID` representing the tile at the target zoom level. * When targetZ is greater than the current canonical z, the canonical coordinates are unchanged. * When targetZ is less than the current canonical z, the canonical coordinates are updated. * @param targetZ - the zoom level to scale to. Must be less than or equal to this.overscaledZ * @returns a new OverscaledTileID representing the tile at the target zoom level * @throws if targetZ is greater than this.overscaledZ */ scaledTo(targetZ: number): OverscaledTileID; isOverscaled(): boolean; 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$1; /** * Maps tile-local coordinates that may fall outside the `[0, extent)` range * to the correct neighbor tile and the corresponding in-tile position. * * Coordinates can exceed tile bounds when geometry (e.g. symbol labels along * lines) extends across tile edges. This method resolves such coordinates to * the appropriate adjacent tile, wrapping horizontally across world boundaries * and returning `null` when the target falls beyond the polar tile-grid limits. * * When the coordinates are already in bounds, the original tile ID is returned. * * @param x - x coordinate relative to this tile, may be outside `[0, extent)` * @param y - y coordinate relative to this tile, may be outside `[0, extent)` * @param extent - tile coordinate extent, default {@link EXTENT} * @returns the resolved tile ID and in-tile coordinates, or `null` if the * target is beyond the tile grid (e.g. past the poles) */ normalizeCoordinates(x: number, y: number, extent?: number): { tileID: OverscaledTileID; x: number; y: number; } | null; } //#endregion //#region src/util/evented.d.ts /** * A listener method used as a callback to events */ type Listener = (a: any) => any; type Listeners<EventType extends Record<string, any>> = { [_ in keyof EventType]?: Listener[]; }; /** * The event class */ declare class Event$1 { readonly type: string; /** * The object that fired the event. Set when the event is fired, and narrowed to a more * specific type (e.g. `Map`, `Marker`) by the event subclasses. */ target?: unknown; constructor(type: string, data?: any); } type ErrorLike = { message: string; }; /** * An error event */ declare class ErrorEvent$1 extends Event$1 { error: ErrorLike; constructor(error: ErrorLike, data?: any); } /** * Methods mixed in to other classes for event capabilities. * * @group Event Related */ declare abstract class Evented<EventType extends Record<string, any> = Record<string, any>> { _listeners: Listeners<EventType>; _oneTimeListeners: Listeners<EventType>; _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<T extends keyof EventType>(type: T, listener: (event: EventType[T]) => void): Subscription; /** * Removes a previously registered event listener. * * @param type - The event type to remove listeners for. * @param listener - The listener function to remove. */ off<T extends keyof EventType>(type: T, listener: (event: EventType[T]) => void): 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. * @returns a promise that resolves with the event */ once<T extends keyof EventType>(type: T): Promise<EventType[T]>; /** * 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` when a listener is provided */ once<T extends keyof EventType>(type: T, listener: (event: EventType[T]) => void): this; 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; } //#endregion //#region src/util/vectortile_to_geojson.d.ts /** * A helper for type to omit a property from a type */ type DistributiveKeys<T> = T extends T ? keyof T : never; /** * A helper for type to omit a property from a type */ type DistributiveOmit<T, K extends DistributiveKeys<T>> = T extends unknown ? Omit<T, K> : never; /** * An extended geojson feature used by the events to return data to the listener */ type MapGeoJSONFeature = GeoJSONFeature & { layer: DistributiveOmit<LayerSpecification, "source"> & { source: string; }; source: string; sourceLayer?: string; state: { [key: string]: any; }; }; /** * A geojson feature */ declare class GeoJSONFeature { type: "Feature"; _geometry: GeoJSON.Geometry; properties: { [name: string]: any; }; id: number | string | undefined; _x: number; _y: number; _z: number; _vectorTileFeature: VectorTileFeatureLike; constructor(vectorTileFeature: VectorTileFeatureLike, z: number, x: number, y: number, id: string | number | undefined); private projectPoint; private projectLine; get geometry(): GeoJSON.Geometry; set geometry(g: GeoJSON.Geometry); toJSON(): GeoJSON.Feature; } //#endregion //#region src/geo/lng_lat_bounds.d.ts /** * A {@link LngLatBounds} object, an array of {@link LngLatLike} objects in `[sw, ne]` order, * or an array of numbers in `[west, south, east, north]` order. * * @group Geography and Geometry * * @example * ```ts * let v1 = new LngLatBounds( * new LngLat(-73.9876, 40.7661), * new LngLat(-73.9397, 40.8002) * ); * let v2 = new LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]) * let v3 = [[-73.9876, 40.7661], [-73.9397, 40.8002]]; * ``` */ type LngLatBoundsLike = LngLatBounds | [LngLatLike, LngLatLike] | [number, number, number, number]; /** * A `LngLatBounds` object represents a geographical bounding box, * defined by its southwest and northeast points in longitude and latitude. * * If no arguments are provided to the constructor, a `null` bounding box is created. * * Note that any MapLibre GL method that accepts a `LngLatBounds` object as an argument or option * can also accept an `Array` of two {@link LngLatLike} constructs and will perform an implicit conversion. * This flexible type is documented as {@link LngLatBoundsLike}. * * @group Geography and Geometry * * @example * ```ts * let sw = new LngLat(-73.9876, 40.7661); * let ne = new LngLat(-73.9397, 40.8002); * let llb = new LngLatBounds(sw, ne); * ``` * @see [Fit to the bounds of a LineString](https://maplibre.org/maplibre-gl-js/docs/examples/fit-to-the-bounds-of-a-linestring/) */ declare class LngLatBounds { _ne: LngLat; _sw: LngLat; /** * @param sw - The southwest corner of the bounding box. * OR array of 4 numbers in the order of west, south, east, north * OR array of 2 LngLatLike: `[sw, ne]` * @param ne - The northeast corner of the bounding box. * @example * ```ts * let sw = new LngLat(-73.9876, 40.7661); * let ne = new LngLat(-73.9397, 40.8002); * let llb = new LngLatBounds(sw, ne); * ``` * OR * ```ts * let llb = new LngLatBounds([-73.9876, 40.7661, -73.9397, 40.8002]); * ``` * OR * ```ts * let llb = new LngLatBounds([sw, ne]); * ``` */ constructor(sw?: LngLatLike | [number, number, number, number] | [LngLatLike, LngLatLike], ne?: LngLatLike); /** * Set the northeast corner of the bounding box * * @param ne - a {@link LngLatLike} object describing the northeast corner of the bounding box. */ setNorthEast(ne: LngLatLike): this; /** * Set the southwest corner of the bounding box * * @param sw - a {@link LngLatLike} object describing the southwest corner of the bounding box. */ setSouthWest(sw: LngLatLike): this; /** * Extend the bounds to include a given LngLatLike or LngLatBoundsLike. * * @param obj - object to extend to */ extend(obj: LngLatLike | LngLatBoundsLike): this; /** * Returns the geographical coordinate equidistant from the bounding box's corners. * * @returns The bounding box's center. * @example * ```ts * let llb = new LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]); * llb.getCenter(); // = LngLat {lng: -73.96365, lat: 40.78315} * ``` */ getCenter(): LngLat; /** * Returns the southwest corner of the bounding box. * * @returns The southwest corner of the bounding box. */ getSouthWest(): LngLat; /** * Returns the northeast corner of the bounding box. * * @returns The northeast corner of the bounding box. */ getNorthEast(): LngLat; /** * Returns the northwest corner of the bounding box. * * @returns The northwest corner of the bounding box. */ getNorthWest(): LngLat; /** * Returns the southeast corner of the bounding box. * * @returns The southeast corner of the bounding box. */ getSouthEast(): LngLat; /** * Returns the west edge of the bounding box. * * @returns The west edge of the bounding box. */ getWest(): number; /** * Returns the south edge of the bounding box. * * @returns The south edge of the bounding box. */ getSouth(): number; /** * Returns the east edge of the bounding box. * * @returns The east edge of the bounding box. */ getEast(): number; /** * Returns the north edge of the bounding box. * * @returns The north edge of the bounding box. */ getNorth(): number; /** * Returns the bounding box represented as an array. * * @returns The bounding box represented as an array, consisting of the * southwest and northeast coordinates of the bounding represented as arrays of numbers. * @example * ```ts * let llb = new LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]); * llb.toArray(); // = [[-73.9876, 40.7661], [-73.9397, 40.8002]] * ``` */ toArray(): [[number, number], [number, number]]; /** * Return the bounding box represented as a string. * * @returns The bounding box represents as a string of the format * `'LngLatBounds(LngLat(lng, lat), LngLat(lng, lat))'`. * @example * ```ts * let llb = new LngLatBounds([-73.9876, 40.7661], [-73.9397, 40.8002]); * llb.toString(); // = "LngLatBounds(LngLat(-73.9876, 40.7661), LngLat(-73.9397, 40.8002))" * ``` */ toString(): string; /** * Check if the bounding box is an empty/`null`-type box. * * @returns True if bounds have been defined, otherwise false. */ isEmpty(): boolean; /** * Check if the point is within the bounding box. * * @param lnglat - geographic point to check against. * @returns `true` if the point is within the bounding box. * @example * ```ts * let llb = new LngLatBounds( * new LngLat(-73.9876, 40.7661), * new LngLat(-73.9397, 40.8002) * ); * * let ll = new LngLat(-73.9567, 40.7789); * * console.log(llb.contains(ll)); // = true * ``` */ contains(lnglat: LngLatLike): boolean; /** * Checks if this bounding box intersects with another bounding box. * * Returns true if the bounding boxes share any area, including cases where * they only touch along an edge or at a corner. * * This method properly handles cases where either or both bounding boxes cross * the antimeridian (date line). */ intersects(other: LngLatBoundsLike): boolean; /** * Converts an array to a `LngLatBounds` object. * * If a `LngLatBounds` object is passed in, the function returns it unchanged. * * Internally, the function calls {@link LngLat.convert} to convert arrays to `LngLat` values. * * @param input - An array of two coordinates to convert, or a `LngLatBounds` object to return. * @returns A new `LngLatBounds` object, if a conversion occurred, or the original `LngLatBounds` object. * @example * ```ts * let arr = [[-73.9876, 40.7661], [-73.9397, 40.8002]]; * let llb = LngLatBounds.convert(arr); // = LngLatBounds {_sw: LngLat {lng: -73.9876, lat: 40.7661}, _ne: LngLat {lng: -73.9397, lat: 40.8002}} * ``` */ static convert(input: LngLatBoundsLike | null): LngLatBounds; /** * Returns a `LngLatBounds` from the coordinates extended by a given `radius`. The returned `LngLatBounds` completely contains the `radius`. * * @param center - center coordinates of the new bounds. * @param radius - Distance in meters from the coordinates to extend the bounds. * @returns A new `LngLatBounds` object representing the coordinates extended by the `radius`. * @example * ```ts * let center = new LngLat(-73.9749, 40.7736); * LngLatBounds.fromLngLat(100).toArray(); // = [[-73.97501862141328, 40.77351016847229], [-73.97478137858673, 40.77368983152771]] * ``` */ static fromLngLat(center: LngLat, radius?: number): LngLatBounds; /** * Adjusts the given bounds to handle the case where the bounds cross the 180th meridian (antimeridian). * * @returns The adjusted LngLatBounds * @example * ```ts * let bounds = new LngLatBounds([175.813127, -20.157768], [-178. 340903, -15.449124]); * let adjustedBounds = bounds.adjustAntiMeridian(); * // adjustedBounds will be: [[175.813127, -20.157768], [181.659097, -15.449124]] * ``` */ adjustAntiMeridian(): LngLatBounds; } //#endregion //#region src/util/worker_pool.d.ts /** * Constructs a worker pool. */ declare class WorkerPool { static workerCount: number; active: { [_ in number | string]: boolean; }; workersPromise: Promise<ActorTarget[]> | null; constructor(); acquire(mapId: number | string): Promise<ActorTarget[]>; release(mapId: number | string): void; isPreloaded(): boolean; numActive(): number; } //#endregion //#region src/util/dispatcher.d.ts /** * Responsible for sending messages from a {@link Source} to an associated worker source (usually with the same name). */ declare class Dispatcher { workerPool: WorkerPool; actors: Actor[]; actorsPromise: Promise<Actor[]>; currentActor: number; id: string | number; private removed; constructor(workerPool: WorkerPool, mapId: string | number); private initActors; /** * Broadcast a message to all Workers. */ broadcast<T extends MessageType>(type: T, data: RequestResponseMessageMap[T][0]): Promise<Array<RequestResponseMessageMap[T][1]>>; /** * Acquires an actor to dispatch messages to. The actors are distributed in round-robin fashion. * @returns An actor object backed by a web worker for processing messages. */ getActor(): Promise<Actor>; waitForInitComplete(): Promise<void>; getReadyActor(): Actor; remove(mapRemoved?: boolean): void; registerMessageHandler<T extends MessageType>(type: T, handler: MessageHandler<T>): Promise<void>; unregisterMessageHandler<T extends MessageType>(type: T): Promise<void>; } /** * This function is used to get the global dispatcher that is shared across all maps instances. * It is used by the main thread to send messages to the workers, and by the workers to send messages back to the main thread. * If you import a script into the worker and need to send a message to the workers to pass some parameters for example, * you can use this function to get the global dispatcher and send a message to the workers. * @returns The global dispatcher instance. */ declare function getGlobalDispatcher(): Dispatcher; //#endregion //#region src/util/transferable_grid_index.d.ts type SerializedGrid = { buffer: ArrayBuffer; }; declare class TransferableGridIndex { cells: number[][]; arrayBuffer: ArrayBuffer; d: number; keys: number[]; bboxes: number[]; n: number; extent: number; padding: number; scale: any; uid: number; min: number; max: number; constructor(extent: number | ArrayBuffer, n?: number, padding?: number); insert(key: number, x1: number, y1: number, x2: number, y2: number): void; _insertReadonly(): void; _insertCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, uid: number): void; query(x1: number, y1: number, x2: number, y2: number, intersectionTest?: (x1: number, y1: number, x2: number, y2: number) => boolean): number[]; _queryCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, result: number[], seenUids: Record<number, boolean>, intersectionTest: (x1: number, y1: number, x2: number, y2: number) => boolean): void; _forEachCell(x1: number, y1: number, x2: number, y2: number, fn: Function, arg1: unknown, arg2: unknown, intersectionTest?: (x1: number, y1: number, x2: number, y2: number) => boolean): void; _convertFromCellCoord(x: number): number; _convertToCellCoord(x: number): number; toArrayBuffer(): ArrayBuffer; static serialize(grid: TransferableGridIndex, transferables?: T