About edit GeoJson

If I load two shp files in GeoJson format: Cesium.GeoJsonDataSource.load(Url, geoJsonOptions) .then(dataSource => { viewer.dataSources.add(dataSource);, They were placed in the “dataSource”, What I need to do is, after loading, I may need to modify the layer color of one of the GeoJson. I tried const data=viewer. dataSources. _dataSources to retrieve the “GeoJson” in “dataSources”, and it did indeed retrieve it, like this:


The current issue is that I am unable to retrieve the second or third GeoJson, no matter what I do, I can only get the first GeoJson, use such code like: ‘data[1]’, ‘data[‘1’]’, and as shown in the picture, it displays “length=3”, but when I use “data. length”, it always outputs “1”, this is unbelievable. What I want to ask is, how can I edit the color of each GeoJson layer in this situation?

Hi @AMily,
Viewer.datasources is a DataSourceCollection. Instead of accessing the private ._dataSources array (which could have undocumented behavior), have you tried using the public method DataSourceCollection.prototype.get?

As for changing the layer color, perhaps you could take a look at this Sandcastle.