UNPKG

@allmaps/maplibre

Version:

MapLibre classes for Allmaps

63 lines (61 loc) 2.12 kB
import { Map as MaplibreMap, CustomLayerInterface, LngLatBoundsLike } from 'maplibre-gl'; import { BaseWarpedMapLayer } from '@allmaps/warpedmaplayer'; import { WebGL2RenderOptions } from '@allmaps/render/webgl2'; export type SpecificMapLibreWarpedMapLayerOptions = { layerId: string; layerType: 'custom'; layerRenderingMode: '2d'; }; export type MapLibreWarpedMapLayerOptions = SpecificMapLibreWarpedMapLayerOptions & Partial<WebGL2RenderOptions>; /** * WarpedMapLayer class. * * This class renders maps from a IIIF Georeference Annotation on a MapLibre map. * WarpedMapLayer is implemented using MapLibre's [CustomLayerInterface](https://maplibre.org/maplibre-gl-js/docs/API/interfaces/maplibregl.CustomLayerInterface/). */ export declare class WarpedMapLayer extends BaseWarpedMapLayer<SpecificMapLibreWarpedMapLayerOptions> implements CustomLayerInterface { id: string; type: 'custom'; renderingMode: '2d'; map?: MaplibreMap; /** * Creates a WarpedMapLayer instance * * @param id - Unique ID for this layer * @param options - options */ constructor(options?: Partial<MapLibreWarpedMapLayerOptions>); /** * Method called when the layer has been added to the Map. * * @param map - The Map this custom layer was just added to. * @param gl - The WebGL 2 context for the map. */ onAdd(map: MaplibreMap, gl: WebGL2RenderingContext): void; /** * Method called when the layer has been removed from the Map. */ onRemove(): void; /** * Get the bounding box of all maps as a MapLibre LngLatBoundsLike object * * This is the default MapLibre getBounds() function * * Result is in longitude/latitude `EPSG:4326` coordinates. * * @returns bounding box of all warped maps */ getBounds(): LngLatBoundsLike | undefined; /** * Render the layer. */ render(): void; /** * Trigger the native update function of the map */ nativeUpdate(): void; /** * Pass events */ nativePassWarpedMapEvent(event: Event): void; }