fromProviderAsync
fun fromProviderAsync(imageryProviderPromise: Promise<ImageryProvider>, options: ImageryLayer.ConstructorOptions): ImageryLayer(source)
Create a new imagery layer from an asynchronous imagery provider. The layer will handle any asynchronous loads or errors, and begin rendering the imagery layer once ready.
// Create a new base layer
const viewer = new Viewer("cesiumContainer", {
baseLayer: fromProviderAsync(IonImageryProvider.fromAssetId(3812));
});
Content copied to clipboard
// Add a new transparent layer
const imageryLayer = ImageryLayer.fromProviderAsync(IonImageryProvider.fromAssetId(3812));
imageryLayer.alpha = 0.5;
viewer.imageryLayers.add(imageryLayer);
Content copied to clipboard
// Handle loading events
const imageryLayer = ImageryLayer.fromProviderAsync(IonImageryProvider.fromAssetId(3812));
viewer.imageryLayers.add(imageryLayer);
imageryLayer.readyEvent.addEventListener(provider => {
imageryLayer.provider.errorEvent.addEventListener(error => {
alert(`Encountered an error while loading imagery tiles! ${error}`);
});
});
imageryLayer.errorEvent.addEventListener(error => {
alert(`Encountered an error while creating an imagery layer! ${error}`);
});
Content copied to clipboard
Return
The created imagery layer.
Parameters
imageryProviderPromise
A promise which resolves to a imagery provider
options
An object describing initialization options