@allmaps/openlayers
Version:
OpenLayers classes for Allmaps
716 lines (715 loc) • 28.3 kB
JavaScript
import { OLWarpedMapEvent } from "./OLWarpedMapEvent.js";
import proj4 from "proj4";
import Layer from "ol/layer/Layer.js";
import { WebGL2Renderer } from "@allmaps/render/webgl2";
import { Viewport, WarpedMapEvent, WarpedMapEventType } from "@allmaps/render";
import { BaseWarpedMapLayer } from "@allmaps/warpedmaplayer";
import { mergeOptions, mergePartialOptions } from "@allmaps/stdlib";
import { projectionDefinitionToAntialiasedDefinition } from "@allmaps/project";
//#region src/WarpedMapLayer.ts
var DEFAULT_SPECIFIC_OPENLAYERS_WARPED_MAP_LAYER_OPTIONS = {};
/**
* 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).
*/
var WarpedMapLayer = class extends Layer {
defaultSpecificWarpedMapLayerOptions;
options;
container;
canvas;
gl;
renderer;
canvasSize = [0, 0];
registeredProjections;
#resizeObserver;
/**
* Creates a WarpedMapLayer instance
* @param options - the WebGL2 renderer options
*/
constructor(options) {
super({});
this.defaultSpecificWarpedMapLayerOptions = DEFAULT_SPECIFIC_OPENLAYERS_WARPED_MAP_LAYER_OPTIONS;
this.options = mergeOptions(this.defaultSpecificWarpedMapLayerOptions, options);
this.registeredProjections = /* @__PURE__ */ new Map();
const container = document.createElement("div");
this.container = container;
container.style.position = "absolute";
container.style.width = "100%";
container.style.height = "100%";
container.classList.add("ol-layer");
container.classList.add("allmaps-warped-map-layer");
const canvas = document.createElement("canvas");
canvas.style.position = "absolute";
canvas.style.left = "0";
canvas.style.width = "100%";
canvas.style.height = "100%";
container.appendChild(canvas);
const gl = canvas.getContext("webgl2", { premultipliedAlpha: true });
if (!gl) throw new Error("WebGL 2 not available");
this.#resizeObserver = new ResizeObserver(this.resized.bind(this));
this.#resizeObserver.observe(canvas, { box: "content-box" });
this.canvas = canvas;
this.gl = gl;
this.renderer = new WebGL2Renderer(this.gl, options);
this.addEventListeners();
this.canvas.addEventListener("webglcontextlost", this.contextLost.bind(this));
this.canvas.addEventListener("webglcontextrestored", this.contextRestored.bind(this));
}
/**
* 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() {
return this.renderer.warpedMapList.getMapsBbox({ projection: { definition: "EPSG:4326" } });
}
/**
* Keep a list of registered projections.
*
* Can optionally be used to complement OpenLayer's `register(proj4)` function.
*
* To use viewport projections in OpenLayers, add projections to proj4 and register proj4
* (Example: https://openlayers.org/en/latest/examples/scaleline-indiana-east.html).
* WarpedMapLayer reads the view's projections code, gets its definition from proj4.defs
* (thanks to the register() function) and constructs a new Projection type (defined in @allmap/project).
*
* Using this function on top of OpenLayer's `register()`,
* WarpedMapLayer will look up the code in the registered projections first for a matching `id`
* and, if found, use this projection. This ways relavant projection information (id, name, ...)
* can be passed and used to all Allmaps packages.
*
* Newly registered projection overwrite older ones with the same id.
*/
registerProjections(projections) {
for (const projection of projections) if (projection.id) this.registeredProjections.set(projection.id, projection);
}
/**
* Disposes all WebGL resources and cached tiles
*/
dispose() {
this.renderer.destroy();
const extension = this.gl?.getExtension("WEBGL_lose_context");
if (extension) extension.loseContext();
const canvas = this.gl?.canvas;
if (canvas) {
canvas.width = 1;
canvas.height = 1;
}
this.#resizeObserver.disconnect();
this.removeEventListeners();
this.canvas?.removeEventListener("webglcontextlost", this.contextLost.bind(this));
this.canvas?.removeEventListener("webglcontextrestored", this.contextRestored.bind(this));
}
/**
* Render the layer.
* @param frameState - OpenLayers frame state
* @returns The rendered element
*/
render(frameState) {
if (this.canvas) this.resizeCanvas(this.canvas, this.canvasSize);
const rotation = frameState.viewState.rotation;
const devicePixelRatio = window.devicePixelRatio;
const projectionCode = frameState.viewState.projection.getCode();
const projectionDefinitionFromProj4 = proj4.defs(projectionCode).projStr;
let projection;
if (this.registeredProjections.has(projectionCode)) projection = this.registeredProjections.get(projectionCode);
else if (projectionDefinitionFromProj4) projection = { definition: projectionDefinitionToAntialiasedDefinition(projectionDefinitionFromProj4) };
else throw new Error(`Unknown projection code: ${projectionCode}`);
const viewportSize = frameState.size;
const viewportCenter = frameState.viewState.center;
const projectedGeoPerViewportScale = frameState.viewState.resolution;
const viewport = new Viewport(viewportSize, viewportCenter, projectedGeoPerViewportScale, {
rotation,
devicePixelRatio,
projection
});
this.renderer.render(viewport);
return this.container;
}
resized(entries) {
for (const entry of entries) {
const width = entry.contentRect.width;
const height = entry.contentRect.height;
const dpr = window.devicePixelRatio;
this.canvasSize = [Math.round(width * dpr), Math.round(height * dpr)];
}
this.nativeUpdate();
}
resizeCanvas(canvas, [width, height]) {
const needResize = canvas.width !== width || canvas.height !== height;
if (needResize) {
canvas.width = width;
canvas.height = height;
}
return needResize;
}
nativeUpdate() {
this.changed();
}
nativePassWarpedMapEvent(event) {
if (event instanceof WarpedMapEvent) {
const olEvent = new OLWarpedMapEvent(event.type, event.data);
this.dispatchEvent(olEvent);
}
}
/**
* Adds a Georeference Annotation
*
* @param annotation - Georeference Annotation
* @param mapOptions - Map options
* @returns Map IDs of the maps that were added, or an error per map
*/
addGeoreferenceAnnotation(annotation, mapOptions) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
const results = this.renderer.addGeoreferenceAnnotation(annotation, mapOptions);
this.nativeUpdate();
return results;
}
/**
* Removes a Georeference Annotation
*
* @param annotation - Georeference Annotation
* @returns Map IDs of the maps that were removed, or an error per map
*/
removeGeoreferenceAnnotation(annotation) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
const results = this.renderer.warpedMapList.removeGeoreferenceAnnotation(annotation);
this.nativeUpdate();
return results;
}
/**
* Adds a Georeference Annotation by URL
*
* @param annotationUrl - URL of a Georeference Annotation
* @param mapOptions - Map options
* @returns Map IDs of the maps that were added, or an error per map
*/
async addGeoreferenceAnnotationByUrl(annotationUrl, mapOptions) {
const annotation = await fetch(annotationUrl).then((response) => response.json());
return this.addGeoreferenceAnnotation(annotation, mapOptions);
}
/**
* Removes a Georeference Annotation by URL
*
* @param annotationUrl - URL of a Georeference Annotation
* @returns Map IDs of the maps that were removed, or an error per map
*/
async removeGeoreferenceAnnotationByUrl(annotationUrl) {
const annotation = await fetch(annotationUrl).then((response) => response.json());
return this.removeGeoreferenceAnnotation(annotation);
}
/**
* Adds a Georeferenced Map
*
* @param georeferencedMap - Georeferenced Map
* @param mapOptions - Map options
* @returns Map ID of the map that was added
*/
addGeoreferencedMap(georeferencedMap, mapOptions) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
const result = this.renderer.addGeoreferencedMap(georeferencedMap, mapOptions);
this.nativeUpdate();
return result;
}
/**
* Removes a Georeferenced Map
*
* @param georeferencedMap - Georeferenced Map
* @returns Map ID of the map that was removed
*/
removeGeoreferencedMap(georeferencedMap) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
const result = this.renderer.warpedMapList.removeGeoreferencedMap(georeferencedMap);
this.nativeUpdate();
return result;
}
/**
* Removes a Georeferenced Map by its ID
*
* @param mapId - Map ID of the georeferenced map to remove
* @returns Map ID of the map that was removed
*/
removeGeoreferencedMapById(mapId) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
const result = this.renderer.warpedMapList.removeGeoreferencedMapById(mapId);
this.nativeUpdate();
return result;
}
/**
* Adds image information to the WarpedMapList's image information cache
*
* @param imageInfos - Image informations
* @returns Image IDs of the image informations that were added
*/
addImageInfos(imageInfos) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
const result = this.renderer.warpedMapList.addImageInfos(imageInfos);
this.nativeUpdate();
return result;
}
/**
* Adds sprites to the Renderer's sprite tile cache
*
* This adds tiles from sprites to warped maps in WarpedMapList. Load maps before running this function.
* This uses the image info of related maps. When using addImageInfos(), call it before calling this function.
*
* @param sprites - Sprites
* @param imageUrl - Image url
* @param imageSize - Image size
*/
async addSprites(sprites, imageUrl, imageSize) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
await this.renderer.addSprites(sprites, imageUrl, imageSize);
this.nativeUpdate();
}
/**
* Get the WarpedMapList object that contains a list of the warped maps of all loaded maps
*/
getWarpedMapList() {
BaseWarpedMapLayer.assertRenderer(this.renderer);
return this.renderer.warpedMapList;
}
/**
* Get mapIds for all maps in the layer
*
* Note: more selection options are available on this function of WarpedMapList
*
* @returns The mapIds of all maps
*/
getMapIds() {
BaseWarpedMapLayer.assertRenderer(this.renderer);
return this.renderer.warpedMapList.getMapIds();
}
/**
* Get the WarpedMap instances for all maps, or all selected maps
*
* If no argument is passed, the WarpedMap instance of all maps in the layer is passed
*
* Note: more selection options are available on this function of WarpedMapList
*
* @param mapIds - Map IDs
* @returns The WarpedMap instance of all (selected) map
*/
getWarpedMaps(mapIds) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
return this.renderer.warpedMapList.getWarpedMaps({ mapIds });
}
/**
* Get the WarpedMap instance for a map
*
* @param mapId - Map ID of the requested WarpedMap instance
*/
getWarpedMap(mapId) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
return this.renderer.warpedMapList.getWarpedMap(mapId);
}
/**
* Get the center of the bounding box of all maps in the layer
*
* The result is returned in lon-lat `EPSG:4326` by default.
*
* Note: more selection options are available on this function of WarpedMapList
*
* @param options - Mask and projection options, defaults to applied mask and current projection
* @returns The center of the bbox of all maps, in the chosen projection, or undefined if there were no maps.
*/
getCenter(options) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
return this.renderer.warpedMapList.getMapsCenter(options);
}
/**
* Get the center of the bounding box of all selected maps
*
* The result is returned in lon-lat `EPSG:4326` by default.
*
* Note: more selection options are available on this function of WarpedMapList
*
* @param mapIds - Map IDs
* @param options - Mask and projection options, defaults to applied mask and current projection
* @returns The center of the bbox of all selected maps, in the chosen projection, or undefined if there were no maps matching the selection.
*/
getMapsCenter(mapIds, options) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
return this.renderer.warpedMapList.getMapsCenter(mergePartialOptions({ mapIds }, options));
}
/**
* Get the bounding box of all maps in the layer
*
* The result is returned in lon-lat `EPSG:4326` by default.
*
* Note: more selection options are available on this function of WarpedMapList
*
* @param options - Mask and projection options, defaults to applied mask and current projection
* @returns The bbox of all maps, in the chosen projection, or undefined if there were no maps.
*/
getBbox(options) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
return this.renderer.warpedMapList.getMapsBbox(options);
}
/**
* Get the bounding box of all selected maps
*
* The result is returned in lon-lat `EPSG:4326` by default.
*
* Note: more selection options are available on this function of WarpedMapList
*
* @param mapIds - Map IDs
* @param options - Mask and projection options, defaults to applied mask and current projection
* @returns The bbox of all selected maps, in the chosen projection, or undefined if there were no maps matching the selection.
*/
getMapsBbox(mapIds, options) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
return this.renderer.warpedMapList.getMapsBbox(mergePartialOptions({ mapIds }, options));
}
/**
* Get the convex hull of all maps in the layer
*
* The result is returned in lon-lat `EPSG:4326` by default.
*
* Note: more selection options are available on this function of WarpedMapList
*
* @param mapIds - Map IDs
* @param options - Mask and projection options, defaults to applied mask and current projection
* @returns The convex hull of all maps, in the chosen projection, or undefined if there were no maps.
*/
getConvexHull(options) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
return this.renderer.warpedMapList.getMapsConvexHull(options);
}
/**
* Get the convex hull of all selected maps maps
*
* The result is returned in lon-lat `EPSG:4326` by default.
*
* Note: more selection options are available on this function of WarpedMapList
*
* @param mapIds - Map IDs
* @param options - Mask and projection options, defaults to applied mask and current projection
* @returns The convex hull of all selected maps, in the chosen projection, or undefined if there were no maps matching the selection.
*/
getMapsConvexHull(mapIds, options) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
return this.renderer.warpedMapList.getMapsConvexHull(mergePartialOptions({ mapIds }, options));
}
/**
* Get the z-index of a map
*
* @param mapId - Map ID for which to get the z-index
* @returns The z-index of a map
*/
getMapZIndex(mapId) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
return this.renderer.warpedMapList.getMapZIndex(mapId);
}
/**
* Get the layer opacity
*
* Returns a number between 0 and 1 (the default)
*/
getOpacity() {
return this.getLayerOptions().opacity ?? this.getDefaultOptions().opacity;
}
/**
* Get the default options the layer
*/
getDefaultOptions() {
BaseWarpedMapLayer.assertRenderer(this.renderer);
return mergeOptions(this.defaultSpecificWarpedMapLayerOptions, this.renderer.getDefaultOptions());
}
/**
* Get the default options of a map
*
* These come from the default option settings for WebGL2WarpedMaps and the map's georeferenced map proporties
*
* @param mapId - Map ID for which the options apply
*/
getMapDefaultOptions(mapId) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
return this.renderer.getMapDefaultOptions(mapId);
}
/**
* Get the layer options
*/
getLayerOptions() {
BaseWarpedMapLayer.assertRenderer(this.renderer);
return mergePartialOptions(this.options, this.renderer.getOptions());
}
/**
* Get the map-specific options of a map
*
* @param mapId - Map ID for which the options apply
*/
getMapMapOptions(mapId) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
return this.renderer.getMapMapOptions(mapId);
}
/**
* Get the options of a map
*
* These options are the result of merging the default, georeferenced map,
* layer and map-specific options of that map.
*
* @param mapId - Map ID for which the options apply
*/
getMapOptions(mapId) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
return this.renderer.getMapOptions(mapId);
}
/**
* Set the layer opacity
*
* @param opacity - Layer opacity to set
*/
setOpacity(opacity) {
this.setLayerOptions({ opacity });
}
/**
* Set the options
*
* @param options - Options to set
*/
setOptions(options) {
this.options = mergeOptions(this.options, options);
}
/**
* Set the layer options
*
* Doesn't set render options or specific warped map layer options. Use setOptions() instead.
*
* @param layerOptions - Layer options to set
* @param animationOptions - Animation options
* ```js
* warpedMapLayer.setLayerOptions({ transformationType: 'thinPlateSpline' })
* ```
*/
setLayerOptions(layerOptions, animationOptions) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
this.renderer.setListOptions(layerOptions, animationOptions);
}
/**
* Set the transformation type of the layer
*
* @param transformationType - Transformation type to set
* @param animationOptions - Animation options
*/
setLayerTransformationType(transformationType, animationOptions) {
return this.setLayerOptions({ transformationType }, animationOptions);
}
/**
* Set the GCPs of a map
*
* This only sets the map-specific `gcps` option of the map
* (or more specifically of the warped map used for rendering),
* overwriting the original GCPs inferred from the Georeference Annotation.
*
* The original GCPs can be reset by resetting the map-specific GCPs option,
* and stay accessible in the warped map's `map` property.
*
* @param mapId - Map ID for which to set the options
* @param gcps - GCPs to set
* @param animationOptions - Animation options
*/
setMapGcps(mapId, gcps, animationOptions) {
return this.setMapOptions(mapId, { gcps }, animationOptions);
}
/**
* Set the resource mask of a map
*
* This only sets the map-specific `resourceMask` option of the map
* (or more specifically of the warped map used for rendering),
* overwriting the original resource mask inferred from the Georeference Annotation.
*
* The original resource mask can be reset by resetting the map-specific resource mask option,
* and stays accessible in the warped map's `map` property.
*
* @param mapId - Map ID for which to set the options
* @param resourceMask - Resource mask to set
* @param animationOptions - Animation options
*/
setMapResourceMask(mapId, resourceMask, animationOptions) {
return this.setMapOptions(mapId, { resourceMask }, animationOptions);
}
/**
* Set the transformation type of a map
*
* This only sets the map-specific `transformationType` option of the map
* (or more specifically of the warped map used for rendering),
* overwriting the original transformation type inferred from the Georeference Annotation.
*
* The original transformation type can be reset by resetting the map-specific transformation type option,
* and stays accessible in the warped map's `map` property.
*
* @param mapId - Map ID for which to set the options
* @param transformationType - Transformation type to set
* @param animationOptions - Animation options
*/
setMapTransformationType(mapId, transformationType, animationOptions) {
return this.setMapOptions(mapId, { transformationType }, animationOptions);
}
/**
* Set the transformation type of maps
*
* This only sets the map-specific `transformationType` option of the map
* (or more specifically of the warped map used for rendering),
* overwriting the original transformation type inferred from the Georeference Annotation.
*
* The original transformation type can be reset by resetting the map-specific transformation type option,
* and stays accessible in the warped map's `map` property.
*
* @param mapIds - Map IDs for which to set the options
* @param transformationType - Transformation type to set
* @param animationOptions - Animation options
*/
setMapsTransformationType(mapIds, transformationType, animationOptions) {
return this.setMapsOptions(mapIds, { transformationType }, animationOptions);
}
/**
* Set the map-specific options of a map
*
* In general setting a map-specific option
* also sets the corresponding option of the map,
* since these are the result of merging the default, georeferenced map,
* layer and map-specific options of that map.
*
* A special case is setting a map-specific option to `undefined`:
* then the corresponding option is derived from the default, georeferenced map or layer option.
* This is equivalent to using the reset function for map-specific option.
*
* @param mapId - Map ID for which to set the options
* @param mapOptions - Map-specific options to set
* @param animationOptions - Animation options
* @example
* ```js
* warpedMapLayer.setMapOptions(myMapId, { transformationType: 'thinPlateSpline' })
* ```
*/
setMapOptions(mapId, mapOptions, animationOptions) {
return this.setMapsOptions([mapId], mapOptions, animationOptions);
}
setMapsOptions(firstArgument, secondArgument, thirdArgument) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
this.renderer.setMapsOptions(firstArgument, secondArgument, thirdArgument);
}
setMapsAndLayerOptions(firstArgument, secondArgument, thirdArgument, fourthArgument) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
this.renderer.setMapsAndListOptions(firstArgument, secondArgument, thirdArgument, fourthArgument);
}
/**
* Reset the layer options
*
* Undefined option keys reset all options
*
* Doesn't reset render options or specific warped map layer options. Use setOptions() instead.
*
* @param layerOptionKeys - Keys of the layer options to reset
* @param animationOptions - Animation options
*/
resetLayerOptions(layerOptionKeys, animationOptions) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
this.renderer.resetListOptions(layerOptionKeys, animationOptions);
}
resetMapsOptions(firstArgument, secondArgument, thirdArgument) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
this.renderer.resetMapsOptions(firstArgument, secondArgument, thirdArgument);
}
resetMapsAndListOptions(firstArgument, secondArgument, thirdArgument, fourthArgument) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
this.renderer.resetMapsAndListOptions(firstArgument, secondArgument, thirdArgument, fourthArgument);
}
/**
* Bring maps to front
* @param mapIds - IDs of the maps
*/
bringMapsToFront(mapIds) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
this.renderer.warpedMapList.bringMapsToFront(mapIds);
this.nativeUpdate();
}
/**
* Send maps to back
* @param mapIds - IDs of the maps
*/
sendMapsToBack(mapIds) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
this.renderer.warpedMapList.sendMapsToBack(mapIds);
this.nativeUpdate();
}
/**
* Bring maps forward
* @param mapIds - IDs of the maps
*/
bringMapsForward(mapIds) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
this.renderer.warpedMapList.bringMapsForward(mapIds);
this.nativeUpdate();
}
/**
* Send maps backward
* @param mapIds - IDs of the maps
*/
sendMapsBackward(mapIds) {
BaseWarpedMapLayer.assertRenderer(this.renderer);
this.renderer.warpedMapList.sendMapsBackward(mapIds);
this.nativeUpdate();
}
/**
* Removes all warped maps from the layer
*/
clear() {
BaseWarpedMapLayer.assertRenderer(this.renderer);
this.renderer.clear();
this.nativeUpdate();
}
contextLost(event) {
event.preventDefault();
this.renderer?.contextLost();
}
contextRestored(event) {
event.preventDefault();
this.renderer?.contextRestored();
}
addEventListeners() {
if (!this.renderer) return;
this.renderer.warpedMapList.addEventListener(WarpedMapEventType.IMAGEINFOSADDED, this.nativePassWarpedMapEvent.bind(this));
this.renderer.warpedMapList.addEventListener(WarpedMapEventType.WARPEDMAPADDED, this.nativePassWarpedMapEvent.bind(this));
this.renderer.warpedMapList.addEventListener(WarpedMapEventType.WARPEDMAPREMOVED, this.nativePassWarpedMapEvent.bind(this));
this.renderer.addEventListener(WarpedMapEventType.WARPEDMAPENTERED, this.nativePassWarpedMapEvent.bind(this));
this.renderer.addEventListener(WarpedMapEventType.WARPEDMAPLEFT, this.nativePassWarpedMapEvent.bind(this));
this.renderer.addEventListener(WarpedMapEventType.IMAGELOADED, this.nativeUpdate.bind(this));
this.renderer.addEventListener(WarpedMapEventType.ERROR, this.nativePassWarpedMapEvent.bind(this));
this.renderer.tileCache.addEventListener(WarpedMapEventType.MAPTILELOADED, this.nativePassWarpedMapEvent.bind(this));
this.renderer.spritesTileCache.addEventListener(WarpedMapEventType.MAPTILESLOADEDFROMSPRITES, this.nativePassWarpedMapEvent.bind(this));
this.renderer.tileCache.addEventListener(WarpedMapEventType.MAPTILEDELETED, this.nativePassWarpedMapEvent.bind(this));
this.renderer.tileCache.addEventListener(WarpedMapEventType.FIRSTMAPTILELOADED, this.nativePassWarpedMapEvent.bind(this));
this.renderer.tileCache.addEventListener(WarpedMapEventType.ALLREQUESTEDTILESLOADED, this.nativePassWarpedMapEvent.bind(this));
this.renderer.warpedMapList.addEventListener(WarpedMapEventType.CLEARED, this.nativeUpdate.bind(this));
this.renderer.warpedMapList.addEventListener(WarpedMapEventType.PREPARECHANGE, this.nativePassWarpedMapEvent.bind(this));
this.renderer.warpedMapList.addEventListener(WarpedMapEventType.IMMEDIATECHANGE, this.nativePassWarpedMapEvent.bind(this));
this.renderer.warpedMapList.addEventListener(WarpedMapEventType.ANIMATEDCHANGE, this.nativePassWarpedMapEvent.bind(this));
this.renderer.addEventListener(WarpedMapEventType.CHANGED, this.nativeUpdate.bind(this));
}
removeEventListeners() {
if (!this.renderer) return;
this.renderer.warpedMapList.removeEventListener(WarpedMapEventType.IMAGEINFOSADDED, this.nativePassWarpedMapEvent.bind(this));
this.renderer.warpedMapList.removeEventListener(WarpedMapEventType.WARPEDMAPADDED, this.nativePassWarpedMapEvent.bind(this));
this.renderer.warpedMapList.removeEventListener(WarpedMapEventType.WARPEDMAPREMOVED, this.nativePassWarpedMapEvent.bind(this));
this.renderer.removeEventListener(WarpedMapEventType.WARPEDMAPENTERED, this.nativePassWarpedMapEvent.bind(this));
this.renderer.removeEventListener(WarpedMapEventType.WARPEDMAPLEFT, this.nativePassWarpedMapEvent.bind(this));
this.renderer.removeEventListener(WarpedMapEventType.IMAGELOADED, this.nativeUpdate.bind(this));
this.renderer.removeEventListener(WarpedMapEventType.ERROR, this.nativePassWarpedMapEvent.bind(this));
this.renderer.tileCache.removeEventListener(WarpedMapEventType.MAPTILELOADED, this.nativePassWarpedMapEvent.bind(this));
this.renderer.spritesTileCache.removeEventListener(WarpedMapEventType.MAPTILESLOADEDFROMSPRITES, this.nativePassWarpedMapEvent.bind(this));
this.renderer.tileCache.removeEventListener(WarpedMapEventType.MAPTILEDELETED, this.nativePassWarpedMapEvent.bind(this));
this.renderer.tileCache.removeEventListener(WarpedMapEventType.FIRSTMAPTILELOADED, this.nativePassWarpedMapEvent.bind(this));
this.renderer.tileCache.removeEventListener(WarpedMapEventType.ALLREQUESTEDTILESLOADED, this.nativePassWarpedMapEvent.bind(this));
this.renderer.warpedMapList.removeEventListener(WarpedMapEventType.CLEARED, this.nativeUpdate.bind(this));
this.renderer.warpedMapList.removeEventListener(WarpedMapEventType.PREPARECHANGE, this.nativePassWarpedMapEvent.bind(this));
this.renderer.warpedMapList.removeEventListener(WarpedMapEventType.IMMEDIATECHANGE, this.nativePassWarpedMapEvent.bind(this));
this.renderer.warpedMapList.removeEventListener(WarpedMapEventType.ANIMATEDCHANGE, this.nativePassWarpedMapEvent.bind(this));
this.renderer.removeEventListener(WarpedMapEventType.CHANGED, this.nativeUpdate.bind(this));
}
};
//#endregion
export { WarpedMapLayer };
//# sourceMappingURL=WarpedMapLayer.js.map