@itwin/core-frontend
Version:
iTwin.js frontend components
223 lines • 10 kB
TypeScript
/** @packageDocumentation
* @module MapLayers
*/
import { BeEvent } from "@itwin/core-bentley";
import { Cartographic, ImageMapLayerSettings, ImageSource } from "@itwin/core-common";
import { ScreenViewport } from "../../Viewport";
import { ImageryMapTile, ImageryMapTileTree, MapCartoRectangle, MapFeatureInfoOptions, MapLayerFeatureInfo, MapTilingScheme, QuadId } from "../internal";
import { HitDetail } from "../../HitDetail";
import { DecorateContext } from "../../ViewContext";
/** The status of the map layer imagery provider that lets you know if authentication is needed to request tiles.
* @public
*/
export declare enum MapLayerImageryProviderStatus {
Valid = 0,
RequireAuth = 1
}
/** @internal */
export interface WGS84Extent {
longitudeLeft: number;
longitudeRight: number;
latitudeTop: number;
latitudeBottom: number;
}
/** Abstract class for map layer imagery providers.
* Map layer imagery providers request and provide tile images and other data. Each map layer from a separate source needs its own imagery provider object.
* @beta
*/
export declare abstract class MapLayerImageryProvider {
protected readonly _settings: ImageMapLayerSettings;
protected _usesCachedTiles: boolean;
protected _hasSuccessfullyFetchedTile: boolean;
readonly onStatusChanged: BeEvent<(provider: MapLayerImageryProvider) => void>;
/** @internal */
private readonly _mercatorTilingScheme;
/** @internal */
private readonly _geographicTilingScheme;
/** @internal */
private _status;
/** @internal */
protected _includeUserCredentials: boolean;
/** @internal */
protected readonly onFirstRequestCompleted: BeEvent<() => void>;
/** @internal */
protected _firstRequestPromise: Promise<void> | undefined;
/**
* The status of the map layer imagery provider.
* @public @preview
*/
get status(): MapLayerImageryProviderStatus;
/** Determine if this provider supports map feature info.
* For example, this can be used to show the map feature info tool only when a provider is registered to support it.
* @returns true if provider supports map feature info else return false.
* @public
*/
get supportsMapFeatureInfo(): boolean;
resetStatus(): void;
/** @internal */
get tileSize(): number;
/** @internal */
get maximumScreenSize(): number;
get minimumZoomLevel(): number;
get maximumZoomLevel(): number;
/** @internal */
get usesCachedTiles(): boolean;
get mutualExclusiveSubLayer(): boolean;
/** @internal */
get useGeographicTilingScheme(): boolean;
private _cartoRange?;
/** Validates a cartographic range for NaN and infinite values.
* @param range The cartographic range to validate.
* @returns true if the range is valid, false otherwise.
* @internal
*/
private static isRangeValid;
/** Gets or sets the cartographic range for this provider.
* When setting, if the range is invalid (contains NaN or infinite values), it will be stored as undefined.
* When getting, returns undefined if the range was set to an invalid value.
*/
get cartoRange(): MapCartoRectangle | undefined;
set cartoRange(range: MapCartoRectangle | undefined);
/**
* This value is used internally for various computations, this should not get overriden.
* @internal
*/
protected readonly defaultMinimumZoomLevel = 0;
/**
* This value is used internally for various computations, this should not get overriden.
* @internal
*/
protected readonly defaultMaximumZoomLevel = 22;
/** @internal */
protected get _filterByCartoRange(): boolean;
constructor(_settings: ImageMapLayerSettings, _usesCachedTiles: boolean);
/**
* Initialize the provider by loading the first tile at its default maximum zoom level.
* @beta
*/
initialize(): Promise<void>;
abstract constructUrl(row: number, column: number, zoomLevel: number): Promise<string>;
get tilingScheme(): MapTilingScheme;
/** @deprecated in 5.0 - will not be removed until after 2026-06-13. Use [addAttributions] instead. */
addLogoCards(_cards: HTMLTableElement, _viewport: ScreenViewport): void;
/**
* Add attribution logo cards for the data supplied by this provider to the [[Viewport]]'s logo div.
* @param _cards Logo cards HTML element that may contain custom data attributes.
* @param _viewport Viewport to add logo cards to.
* @beta
*/
addAttributions(cards: HTMLTableElement, vp: ScreenViewport): Promise<void>;
/** @internal */
protected _missingTileData?: Uint8Array;
/** @internal */
get transparentBackgroundString(): string;
/** @internal */
protected _areChildrenAvailable(_tile: ImageryMapTile): Promise<boolean>;
/** @internal */
getPotentialChildIds(quadId: QuadId): QuadId[];
/**
* Get child IDs of a quad and generate tiles based on these child IDs.
* See [[ImageryTileTree._loadChildren]] for the definition of `resolveChildren` where this function is commonly called.
* @param quadId quad to generate child IDs for.
* @param resolveChildren Function that creates tiles from child IDs.
* @beta
*/
protected _generateChildIds(quadId: QuadId, resolveChildren: (childIds: QuadId[]) => void): void;
/** @internal */
generateChildIds(tile: ImageryMapTile, resolveChildren: (childIds: QuadId[]) => void): void;
/**
* Get tooltip text for a specific quad and cartographic position.
* @param strings List of strings to contain tooltip text.
* @param quadId Quad ID to get tooltip for.
* @param _carto Cartographic that may be used to retrieve and/or format tooltip text.
* @param tree Tree associated with the quad to get the tooltip for.
* @internal
*/
getToolTip(strings: string[], quadId: QuadId, _carto: Cartographic, tree: ImageryMapTileTree): Promise<void>;
/** @internal */
getFeatureInfo(featureInfos: MapLayerFeatureInfo[], _quadId: QuadId, _carto: Cartographic, _tree: ImageryMapTileTree, _hit: HitDetail, _options?: MapFeatureInfoOptions): Promise<void>;
/** @internal */
decorate(_context: DecorateContext): void;
/** @internal */
protected getImageFromTileResponse(tileResponse: Response, zoomLevel: number): Promise<ImageSource | undefined>;
/**
* Change the status of this provider.
* Sub-classes should override 'onStatusUpdated' instead of this method.
* @internal
*/
setStatus(status: MapLayerImageryProviderStatus): void;
/** Method called whenever the status changes, giving the opportunity to sub-classes to have a custom behavior.
* @internal
*/
protected onStatusUpdated(_newStatus: MapLayerImageryProviderStatus): void;
/** @internal */
protected setRequestAuthorization(headers: Headers): void;
/** @internal */
makeTileRequest(url: string, timeoutMs?: number, authorization?: string): Promise<Response>;
/** @internal */
makeRequest(url: string, timeoutMs?: number, authorization?: string): Promise<Response>;
/** Returns a map layer tile at the specified settings. */
loadTile(row: number, column: number, zoomLevel: number): Promise<ImageSource | undefined>;
/** @internal */
protected toolTipFromUrl(strings: string[], url: string): Promise<void>;
/** @internal */
matchesMissingTile(tileData: Uint8Array): boolean;
/**
* Calculates the projected x cartesian coordinate in EPSG:3857 from the longitude in EPSG:4326 (WGS84)
* @param longitude Longitude in EPSG:4326 (WGS84)
* @internal
*/
getEPSG3857X(longitude: number): number;
/**
* Calculates the projected y cartesian coordinate in EPSG:3857 from the latitude in EPSG:4326 (WGS84)
* @param latitude Latitude in EPSG:4326 (WGS84)
* @internal
*/
getEPSG3857Y(latitude: number): number;
/**
* Calculates the longitude in EPSG:4326 (WGS84) from the projected x cartesian coordinate in EPSG:3857
* @param x3857 Projected x cartesian coordinate in EPSG:3857
* @internal
*/
getEPSG4326Lon(x3857: number): number;
/**
* Calculates the latitude in EPSG:4326 (WGS84) from the projected y cartesian coordinate in EPSG:3857
* @param y3857 Projected y cartesian coordinate in EPSG:3857
* @internal
*/
getEPSG4326Lat(y3857: number): number;
/**
* Get the bounding box/extents of a tile in EPSG:4326 (WGS84) format.
* Map tile providers like Bing and Mapbox allow the URL to be constructed directly from the zoom level and tile coordinates.
* However, WMS-based servers take a bounding box instead. This method can help get that bounding box from a tile.
* @param row Row of the tile
* @param column Column of the tile
* @param zoomLevel Desired zoom level of the tile
* @internal
*/
getEPSG4326Extent(row: number, column: number, zoomLevel: number): WGS84Extent;
/**
* Get the bounding box/extents of a tile in EPSG:3857 format.
* @param row Row of the tile
* @param column Column of the tile
* @param zoomLevel Desired zoom level of the tile
* @internal
*/
getEPSG3857Extent(row: number, column: number, zoomLevel: number): {
left: number;
right: number;
top: number;
bottom: number;
};
/** @internal */
getEPSG3857ExtentString(row: number, column: number, zoomLevel: number): string;
/** @internal */
getEPSG4326TileExtentString(row: number, column: number, zoomLevel: number, latLongAxisOrdering: boolean): string;
/** @internal */
getEPSG4326ExtentString(tileExtent: WGS84Extent, latLongAxisOrdering: boolean): string;
/** Append custom parameters for settings to provided URL object.
* @internal
*/
protected appendCustomParams(url: string): string;
}
//# sourceMappingURL=MapLayerImageryProvider.d.ts.map