Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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? Any help is appreciated.

like image 930
meen Avatar asked Oct 18 '22 08:10

meen


1 Answers

I found its answer on cesiumjs forum.

In short:

viewer.dataSources.get(0).entities.getById('myid_'+i).polygon.material = colorProperty;
like image 71
meen Avatar answered Oct 21 '22 04:10

meen