useImageryLayerScope
Scope ImageryLayerCollection mutations so created imagery layers are removed automatically when the component unmounts.
WARNING
This is a low-level helper used by useImageryLayer. Prefer useImageryLayer unless you need custom collection management.
Usage
ts
import { ImageryLayer, UrlTemplateImageryProvider } from 'cesium';
import { useImageryLayerScope } from 'vesium';
const { add, remove } = useImageryLayerScope({
destroyOnRemove: true,
});
const layer = add(new ImageryLayer(new UrlTemplateImageryProvider({
url: 'https://example.com/{z}/{x}/{y}.png',
})), 0);
// Async creation is also supported.
add(Promise.resolve(new ImageryLayer(new UrlTemplateImageryProvider({
url: 'https://example.com/{z}/{x}/{y}.png',
}))));Notes
- The target collection defaults to
useViewer().value.imageryLayers. addaccepts an optional insertion index.destroyOnRemoveis forwarded toimageryLayers.remove(layer, destroyOnRemove).
Type Definitions
typescript
import type { ImageryLayer, ImageryLayerCollection } from 'cesium';
import type { MaybeRefOrGetter } from 'vue';
export interface UseImageryLayerScopeOptions {
/**
* The collection of ImageryLayer to be added
* @default useViewer().value.imageryLayers
*/
collection?: MaybeRefOrGetter<ImageryLayerCollection | undefined>;
/**
* The second parameter passed to the `remove` function
*
* `imageryLayers.remove(imageryLayer,destroyOnRemove)`
*/
destroyOnRemove?: boolean;
}
/**
* Make `add` and `remove` operations of `ImageryLayerCollection` scoped,
* automatically remove `ImageryLayer` instance when component is unmounted.
*/
export declare function useImageryLayerScope(options?: UseImageryLayerScopeOptions): import("..").UseCollectionScopeReturn<ImageryLayer, any[], any[], any>;
//# sourceMappingURL=index.d.ts.map