首页 / 浏览问题 / WebGIS / 问题详情
cesium添加entity为label的实体后,修改label的属性不成功
23EXP 2023年10月24日
textEntity = viewer.entities.add({
					position: p,
					name: "文字实体",
					show: true,
					label: {
						text: "文字",
						font: "14px Source Han Sans CN",
						fillColor: new Cesium.Color(255, 255, 255, 1),
						backgroundColor: new Cesium.Color(0, 0, 0, 0.7),
						showBackground: true,
						outline: true,
						outlineColor: new Cesium.Color(0, 0, 0, 1),
						outlineWidth: 10,
						show: true,
					},
				});

我这样添加了label实体
然后我开始修改实体的属性
 

if (textEntity) {
		textEntity.show = true;
		textEntity.label.text = commStore.textData.name;
		textEntity.label.font = commStore.textData.fontSize + "px Source Han Sans CN";
		textEntity.label.outlineWidth = commStore.textData.outWidth;
		textEntity.label.outlineColor = commStore.textData.outLineColor;
		textEntity.label.fillColor = commStore.textData.textColor;
		textEntity.label.backgroundColor = commStore.textData.bgColor;
		textEntity.label.show = true;
		console.log(textEntity)
	} else {
		ElMessage.error("找不到实体text");
	}

但当我这样修改之后,实体却在页面上消失了,该如何解决呢

1个回答

您好

建议您这边可以参考博客这个label参数设定

https://blog.csdn.net/supermapsupport/article/details/90718314

尤其是透明度,偏移,位置,是否随视角远近进行缩放等

4,151EXP 2023年10月24日
...