How to set/change id of entity

I have GeoJSONData, in which I successfully make some changes to each entity.

var promise = _cesium.GeoJsonDataSource.load(GeoJSONData);

promise.then(function(dataSource) {


//Get the array of entities

entities = dataSource.entities.values;

for (var i = 0; i < entities.length; i++) {

var entity = entities[i];

var j=i+1;





I want to access each enity viewer.trackedEntity=viewer.entities.getById() at later stage, but I don’t have each id set by me. So how can i change each entity’s id


It looks like the entity IDs can’t be changed after the entity is created because of how the data is stored. However, when Cesium creates entities from the GeoJSON it looks for an id property for each feature. If you wanted to define your own IDs, I think the best option is to write them into your GeoJSON data files. If that isn’t an option, each entity is given a default unique ID upon creation. You could loop through all of your entities and save these ids in an array so you can reference them later.