I hope the level of ElementCollection can be higher than that of DataSourceCollection
Open the link below
Replace the code inside with my code to reproduce it
const viewer = new Cesium.Viewer("cesiumContainer");
//Example 1: Load with default styling.
Sandcastle.addDefaultToolbarButton("Default styling", async function () {
const dataSource =await Cesium.GeoJsonDataSource.load("../SampleData/ne_10m_us_states.topojson")
viewer.dataSources.add(
dataSource
);
// 设置geojson的zindex发现无效
const entities = dataSource.entities.values;
for (let i = 0; i < entities.length; i++) {
const entity = entities[i]
entity.polygon.zIndex = 1
}
setTimeout(() => {
const redPolygon = viewer.entities.add({
name: "Red polygon on surface",
polygon: {
hierarchy: Cesium.Cartesian3.fromDegreesArray([
-115.0, 37.0, -115.0, 32.0, -107.0, 33.0, -102.0, 31.0, -102.0, 35.0,
]),
material: Cesium.Color.RED,
// 这里设置了zindex发现 entities 任然在dataSource下面显示
zIndex: 20
},
});
}, 1000);
//window.viewer = viewer
});