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.
I found its answer on cesiumjs forum.
In short:
viewer.dataSources.get(0).entities.getById('myid_'+i).polygon.material = colorProperty;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With