@allmaps/openlayers
Version:
OpenLayers classes for Allmaps
321 lines (319 loc) • 11.2 kB
TypeScript
import { default as Layer } from 'ol/layer/Layer.js';
import { WebGL2Renderer, WebGL2WarpedMap } from '@allmaps/render/webgl2';
import { WarpedMapList, WarpedMapLayerOptions } from '@allmaps/render';
import { FrameState } from 'ol/Map.js';
import { Extent } from 'ol/extent';
import { DistortionMeasure, TransformationType } from '@allmaps/transform';
import { Ring, ImageInformations, Gcp } from '@allmaps/types';
export type OpenLayersWarpedMapLayerOptions = WarpedMapLayerOptions;
/**
* WarpedMapLayer class.
*
* This class renders georeferenced maps from a Georeference Annotation on an OpenLayers map.
* WarpedMapLayer is a subclass of [Layer](https://openlayers.org/en/latest/apidoc/module-ol_layer_Layer-Layer.html).
*/
export declare class WarpedMapLayer extends Layer {
container: HTMLElement;
canvas: HTMLCanvasElement;
gl: WebGL2RenderingContext;
canvasSize: [number, number];
renderer: WebGL2Renderer;
private resizeObserver;
/**
* Creates a WarpedMapLayer instance
* @param options - the WebGL2 renderer options
*/
constructor(options?: Partial<OpenLayersWarpedMapLayerOptions>);
/**
* Adds a [Georeference Annotation](https://iiif.io/api/extension/georef/).
* @param annotation - Georeference Annotation
* @returns - the map IDs of the maps that were added, or an error per map
*/
addGeoreferenceAnnotation(annotation: unknown): Promise<(string | Error)[]>;
/**
* Removes a [Georeference Annotation](https://iiif.io/api/extension/georef/).
* @param annotation - Georeference Annotation
* @returns - the map IDs of the maps that were removed, or an error per map
*/
removeGeoreferenceAnnotation(annotation: unknown): Promise<(string | Error)[]>;
/**
* Adds a [Georeference Annotation](https://iiif.io/api/extension/georef/) by URL.
* @param annotationUrl - Georeference Annotation
* @returns - the map IDs of the maps that were added, or an error per map
*/
addGeoreferenceAnnotationByUrl(annotationUrl: string): Promise<(string | Error)[]>;
/**
* Removes a [Georeference Annotation](https://iiif.io/api/extension/georef/) by URL.
* @param annotationUrl - Georeference Annotation
* @returns - the map IDs of the maps that were removed, or an error per map
*/
removeGeoreferenceAnnotationByUrl(annotationUrl: string): Promise<(string | Error)[]>;
/**
* Adds a Georeferenced map.
* @param georeferencedMap - Georeferenced map
* @returns - the map ID of the map that was added, or an error
*/
addGeoreferencedMap(georeferencedMap: unknown): Promise<string | Error>;
/**
* Removes a Georeferenced map.
* @param georeferencedMap - Georeferenced map
* @returns - the map ID of the map that was remvoed, or an error
*/
removeGeoreferencedMap(georeferencedMap: unknown): Promise<string | Error>;
/**
* Returns the WarpedMapList object that contains a list of the warped maps of all loaded maps
* @returns the warped map list
*/
getWarpedMapList(): WarpedMapList<WebGL2WarpedMap>;
/**
* Returns a single map's warped map
* @param mapId - ID of the map
* @returns the warped map
*/
getWarpedMap(mapId: string): WebGL2WarpedMap | undefined;
/**
* Make a single map visible
* @param mapId - ID of the map
*/
showMap(mapId: string): void;
/**
* Make multiple maps visible
* @param mapIds - IDs of the maps
*/
showMaps(mapIds: Iterable<string>): void;
/**
* Make a single map invisible
* @param mapId - ID of the map
*/
hideMap(mapId: string): void;
/**
* Make multiple maps invisible
* @param mapIds - IDs of the maps
*/
hideMaps(mapIds: Iterable<string>): void;
/**
* Returns the visibility of a single map
* @returns - whether the map is visible
*/
isMapVisible(mapId: string): boolean | undefined;
/**
* Sets the resource mask of a single map
* @param mapId - ID of the map
* @param resourceMask - new resource mask
*/
setMapResourceMask(mapId: string, resourceMask: Ring): void;
/**
* Sets the GCOs of a single map
* @param mapId - ID of the map
* @param gcos - new GCPs
*/
setMapGcps(mapId: string, gcps: Gcp[]): void;
/**
* Sets the transformation type of multiple maps
* @param mapIds - IDs of the maps
* @param transformation - new transformation type
*/
setMapsTransformationType(mapIds: Iterable<string>, transformation: TransformationType): void;
/**
* Sets the transformation type of a single map
* @param mapId - ID of the map
* @param transformation - new transformation type
*/
setMapTransformationType(mapId: string, transformation: TransformationType): void;
/**
* Sets the distortion measure of multiple maps
* @param mapIds - IDs of the maps
* @param distortionMeasure - new distortion measure
*/
setMapsDistortionMeasure(mapIds: Iterable<string>, distortionMeasure?: DistortionMeasure): void;
removeGeoreferencedMapById(mapId: string): void;
/**
* Return the bounding box of all visible maps in the layer (inside or outside of the Viewport), in longitude/latitude coordinates.
* @returns - Bounding box of all warped maps
*/
getLonLatExtent(): Extent | undefined;
/**
* Return the bounding box of all visible maps in the layer (inside or outside of the Viewport), in projected coordinates.
* @returns - bounding box of all warped maps
*/
getExtent(): Extent | undefined;
/**
* Bring maps to front
* @param mapIds - IDs of the maps
*/
bringMapsToFront(mapIds: Iterable<string>): void;
/**
* Send maps to back
* @param mapIds - IDs of the maps
*/
sendMapsToBack(mapIds: string[]): void;
/**
* Bring maps forward
* @param mapIds - IDs of the maps
*/
bringMapsForward(mapIds: Iterable<string>): void;
/**
* Send maps backward
* @param mapIds - IDs of the maps
*/
sendMapsBackward(mapIds: Iterable<string>): void;
/**
* Returns the z-index of a single map
* @param mapId - ID of the warped map
* @returns - z-index of the warped map
*/
getMapZIndex(mapId: string): number | undefined;
/**
* Sets the object that caches image information
* @param imageInformations - Object that caches image information
*/
setImageInformations(imageInformations: ImageInformations): void;
/**
* Gets the HTML container element of the layer
* @returns HTML element
*/
getContainer(): HTMLElement;
/**
* Gets the HTML canvas element of the layer
* @returns HTML Canvas element
*/
getCanvas(): HTMLCanvasElement | null;
/**
* Sets the options
*
* @param options - Options
*/
setOptions(options?: Partial<OpenLayersWarpedMapLayerOptions>): void;
/**
* Gets the opacity of a single map
* @param mapId - ID of the map
* @returns Opacity of the map
*/
getMapOpacity(mapId: string): number | undefined;
/**
* Sets the opacity of a single map
* @param mapId - ID of the map
* @param opacity - opacity between 0 and 1, where 0 is fully transparent and 1 is fully opaque
*/
setMapOpacity(mapId: string, opacity: number): void;
/**
* Resets the opacity of a single map to fully opaque
* @param mapId - ID of the map
*/
resetMapOpacity(mapId: string): void;
/**
* Sets the saturation of a single map
* @param saturation - saturation between 0 and 1, where 0 is grayscale and 1 are the original colors
*/
setSaturation(saturation: number): void;
/**
* Resets the saturation of a single map to the original colors
*/
resetSaturation(): void;
/**
* Sets the saturation of a single map
* @param mapId - ID of the map
* @param saturation - saturation between 0 and 1, where 0 is grayscale and 1 are the original colors
*/
setMapSaturation(mapId: string, saturation: number): void;
/**
* Resets the saturation of a single map to the original colors
* @param mapId - ID of the map
*/
resetMapSaturation(mapId: string): void;
/**
* Removes a color from all maps
* @param transformOptions - remove color options
* @param transformOptions.hexColor - hex color to remove
* @param transformOptions.threshold - threshold between 0 and 1
* @param transformOptions.hardness - hardness between 0 and 1
*/
setRemoveColor(options: Partial<{
hexColor: string;
threshold: number;
hardness: number;
}>): void;
/**
* Resets the color removal for all maps
*/
resetRemoveColor(): void;
/**
* Removes a color from a single map
* @param mapId - ID of the map
* @param transformOptions - remove color options
* @param transformOptions.hexColor] - hex color to remove
* @param transformOptions.threshold] - threshold between 0 and 1
* @param transformOptions.hardness] - hardness between 0 and 1
*/
setMapRemoveColor(mapId: string, options: Partial<{
hexColor: string;
threshold: number;
hardness: number;
}>): void;
/**
* Resets the color for a single map
* @param mapId - ID of the map
*/
resetMapRemoveColor(mapId: string): void;
/**
* Sets the colorization for all maps
* @param hexColor - desired hex color
*/
setColorize(hexColor: string): void;
/**
* Resets the colorization for all maps
*/
resetColorize(): void;
/**
* Sets the colorization for a single mapID of the map
* @param mapId - ID of the map
* @param hexColor - desired hex color
*/
setMapColorize(mapId: string, hexColor: string): void;
/**
* Resets the colorization of a single map
* @param mapId - ID of the map
*/
resetMapColorize(mapId: string): void;
/**
* Sets the grid for all maps
* @param enabled - whether to show the grid
*/
setGrid(enabled: boolean): void;
/**
* Resets the grid for all maps
*/
resetGrid(): void;
/**
* Sets the grid for a single mapID of the map
* @param mapId - ID of the map
* @param enabled - whether to show the grid
*/
setMapGrid(mapId: string, enabled: boolean): void;
/**
* Resets the grid of a single map
* @param mapId - ID of the map
*/
resetMapGrid(mapId: string): void;
/**
* Disposes all WebGL resources and cached tiles
*/
dispose(): void;
/**
* Clears: removes all maps
*/
clear(): void;
/**
* Render the layer.
* @param frameState - OpenLayers frame state
* @returns The rendered element
*/
render(frameState: FrameState): HTMLElement;
private resized;
private resizeCanvas;
private contextLost;
private contextRestored;
private addEventListeners;
private removeEventListeners;
private passWarpedMapEvent;
}