Display order of DataSources

I have two data sources viz, firstDataSource and secondDataSource, the firstDataSource being the one that was added to the viewer first.
I am having problem in the order of entities while adding to these datasources.

The following link has the sample example:

Steps:
1. Click "Add to secondDataSourceFirst" - This removes any existing entities from the datasources and, adds green polygon to secondDataSource first and then adds blue polygon to firstDataSource.
2. Click "Add to firstDataSourceFirst" - This removes any existing entities from the datasources and, adds blue polygon to firstDataSource first and then adds green polygon to secondDataSource.

  At this point, note that entities are displayed on the map in the order of datasources added (not in the order of entities added), which means green polygon (from secondDataSource) is always at the top.

3. Click "Clear" - This removes all existing entities from the datasources.
4. Click "Add only to firstDataSource" - This removes any existing entities from firstDataSource and adds blue polygon to firstDatasource.
5. Click "Add only to secondDataSource" - This removes any existing entities from secondDataSource and adds green polygon to secondDataSource.
  At this point, note that the order of entities is same as after step 2.
4. Click "Clear" again.
5. Click "Add only to secondDataSource".
6. Click "Add only to firstDataSource".

Expected: Green polygon should be at the top.
Actual: Blue polygon is at the top.

I am not sure if this is a bug in Cesium or there is something that I am missing. Any help would be really appreciated.

Thanks,
Hari

Hi Hari,

Each DataSource has it’s own EnityCollection, which acts like a layer of entities, so every entity in the “top” data source will be rendered in front of all the entities in the “bottom” data source.

This section on Managing Entities in our Visualizing Spatial Data Tutorial goes more in depth on how we manage entities with entity collections in Cesium.

I hope that helps explain things! I don’t think you are encountering a bug, but please let us know if you still think you are.

Thanks,

Gabby

Thank Gabby for your response.

In the example after step 5 and 6, the entity in the bottom datasource is rendered above the entity in the top datasource. Don't you think the entity in the top datasource should always be rendered at the top?

My expectation in the example was the result after steps 5 and 6 should be same as that I got after steps 1 and 2 or 4 and 5.

Thanks,
Hari