How can I find the label id and change its background color? This is same to HTML concept of “document.getElementById”. What is the “document.getElementByID” for cesium entity-label? I would like to use it function two in this example.
placemark.push(viewer.entities.add({
id: "1234",
orientation: new Cesium.HeadingPitchRoll(0, 0, 0),
position: Cesium.Cartesian3.fromDegrees(parseFloat(lon), parseFloat(lat), 30),
label: {
text: "hello",
verticalOrigin: Cesium.VerticalOrigin.TOP,
font: '20px sans-serif',
fillColor: Cesium.Color.BLACK,
backgroundColor: Cesium.Color.WHITE,
backgroundPadding : new Cesium.Cartesian2(30, 15),
style : Cesium.LabelStyle.FILL_AND_OUTLINE,
showBackground: true
}
var onevalue="";
function one(){
viewer.screenSpaceEventHandler.setInputAction(function(mouse) {
var pickedObject = viewer.scene.pick(mouse.position);
if (Cesium.defined(pickedObject)) {
onevalue = pickedObject.id.id;
two(onevalue);
}
}
}, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
}
function two(){
//how can change the label properties in this function. i.e. I want to change the background color.
entity = viewer.entities.getById(onevalue); // is this the document.getElementById?
entity.label.backgroundColor = Cesium.Color.SKYBLUE;
}