boykely
boykely

Reputation: 381

waiting for scene to be fully rendered in cesium

when loading kml datasource, I want to display a loading image until it can be visualized in the viewer or scene. I tried to handle:

Please anyone can help Thanks Regards

Upvotes: 8

Views: 3780

Answers (2)

Andrew
Andrew

Reputation: 1

Update (i.e. Cesium.viewer.dataSources.add()):

DataSourceCollection:

add(dataSource) → Promise.

Adds a data source to the collection.

...

Returns: A Promise that resolves once the data source has been added to the collection.

(https://cesium.com/docs/cesiumjs-ref-doc/DataSourceCollection.html#add)

Then use the Promise .then() as described in the other answer.

Upvotes: 0

emackey
emackey

Reputation: 12448

Try this instead:

viewer.dataSource.add(datasource); // add empty datasource.
datasource.load(url).then(function () { clearLoader(); });

The .add function returns immediately, even with an empty data source. But the .load function returns a promise that will resolve once the data source is loaded.

Upvotes: 3

Related Questions