How to update polygon material if I know Id of polygon?

I am loading a CZML file in cesium. And want to highlight multiple polygons (like myid_1, myid_2, myid_3) if polygon with id as “myid” is clicked. But I am unable to process it as I am not getting the entity objects of other polygons to process its color change. On click handler is as below.

var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(click) {
    var pickedObject = scene.pick(click.position);
    if (Cesium.defined(pickedObject)) {
        console.log(pickedObject.id instanceof Cesium.Entity);  //returns true
        var colorProperty = Cesium.Color.YELLOW;
        pickedObject.id.polygon.material = new Cesium.ColorMaterialProperty(colorProperty);
    }
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);

How can I get the other related polygons processed on click?

Hello,

You can use entities.getById to get the polygons with similar ids. Here is an example:

var viewer = new Cesium.Viewer(‘cesiumContainer’);
var scene = viewer.scene;

var promise = Cesium.CzmlDataSource.load(‘path/to/file’);
promise.then(function(dataSource) {
viewer.dataSources.add(dataSource);

var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(click) {
    var pickedObject = scene.pick(click.position);
    var entity = pickedObject.id;
    if (dataSource.entities.contains(entity)) {
        var entityId = entity.id;
        var otherId = '';//figure out id of related entities using entityId
        var otherEntity = dataSource.entities.getById(otherId);
        ...
    }
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);

});

``

Best,

Hannah