viewer.entities.getById("SOMEID").polygon.material.color = Cesium.Color.RED;
TypeError: Cannot set property color of #<Object> which has only a getter
Cesium 1.48 is used.
var viewer = new Cesium.Viewer('cesiumContainer');
viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) { viewer.entities.getById("1").polygon.material.color = Cesium.Color.BLUE;}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
var redPolygon = viewer.entities.add({ name : 'Red polygon on surface', id: '1', polygon : { hierarchy : Cesium.Cartesian3.fromDegreesArray([-115.0, 37.0, -115.0, 32.0, -107.0, 33.0, -102.0, 31.0, -102.0, 35.0]), material : Cesium.Color.RED }});
viewer.zoomTo(viewer.entities);
var parentTest = viewer.entities.add(new Cesium.Entity());
var entity = viewer.entities.add({
id : "someId",
parent : parentTest,
customVar1 : Value1,
customVar1 : Value2,
description : "testDescription",
polygon : {
hierarchy : new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArrayHeights(eval("[COORDINATES FOR POLYGON]"))),
material : Cesium.Color.BLUE
}
});
var parentTest = viewer.entities.add(new Cesium.Entity());
var entity = viewer.entities.add({
id : "someId",
parent : parentTest,
customVar1 : Value1,
customVar1 : Value2,
description : "testDescription",
polygon : {
hierarchy : new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArrayHeights(eval("[COORDINATES FOR POLYGON]"))),
material : new Cesium.CallbackProperty(function(material, result) {
console.log("In Here : ", material);
return Cesium.Color.BLUE;
}, isConstant),
}
});
material : new Cesium.ColorMaterialProperty(
new Cesium.CallbackProperty(function(time, result) {
return color;
}, false))When I create entity, If I show/hide it , and then try to change the color, it was throwing the error.
Then Instead of show/hide, I remove that element and create again, that way whenever I click on it I was able to change the color.
Thank you for help, learned new things for callback.