import { ImageryLayer as CesiumImageryLayer } from "cesium"; import { createCesiumComponent, PickCesiumProps, Merge, ConstructorOptions2 } from "../core"; /* @summary `ImageryLayer` is a imargery layer on the globe. Layers are added in order of JSX from the top. ```jsx // Back layer // Front layer ``` is equivalent to: ```js viewer.imageryLayers.add(provider1); viewer.imageryLayers.add(provider2); viewer.imageryLayers.add(provider3); ``` As a result, the layer added at the very end is the frontmost when actually displayed. Note: `imageryProvider` property is read only. See also [guide](/guide#cesium-read-only-properties). */ /* @scope Either: - Inside [Viewer](/components/Viewer) or [CesiumWidget](/components/CesiumWidget) component: the imargery layer will be attached to the ImageryLayerCollection of the Viewer or CesiumWidget. - Inside [ImageryLayerCollection](/components/ImageryLayerCollection) component: same as above */ export type Target = Merge> & { index?: number; }; export type ImageryLayerCesiumProps = PickCesiumProps; export type ImageryLayerCesiumReadonlyProps = PickCesiumProps< Target, typeof cesiumReadonlyProps, "imageryProvider" >; export type ImageryLayerProps = ImageryLayerCesiumProps & ImageryLayerCesiumReadonlyProps; const cesiumProps = [ "alpha", "brightness", "contrast", "hue", "saturation", "gamma", "splitDirection", "minificationFilter", "magnificationFilter", "cutoutRectangle", "show", "nightAlpha", "dayAlpha", "colorToAlpha", "colorToAlphaThreshold", "index", ] as const; const cesiumReadonlyProps = [ "imageryProvider", "rectangle", "maximumAnisotropy", "minimumTerrainLevel", "maximumTerrainLevel", ] as const; const ImageryLayer = createCesiumComponent({ name: "ImageryLayer", create(context, props) { if (!context.imageryLayerCollection) return; const element = new CesiumImageryLayer(props.imageryProvider, props); context.imageryLayerCollection.add(element, props.index); return element; }, destroy(element, context) { if (context.imageryLayerCollection) { context.imageryLayerCollection.remove(element); } }, cesiumProps, cesiumReadonlyProps, }); export default ImageryLayer;