如何在指定位置向实体(例如多边形)添加标签:
这就是我尝试的方法:(entity.polygon = true)
static addLabel(entity) {
entity.myLabel = new Cesium.LabelGraphics({
position : Cesium.Cartesian3.fromDegrees(-75.1641667, 39.9522222),
label : {
text : 'Philadelphia',
font : '24px Helvetica',
fillColor : Cesium.Color.SKYBLUE,
outlineColor : Cesium.Color.BLACK,
outlineWidth : 2,
}
})
}
没有错误,但没有显示在 map 上。
最佳答案
“标签”是实体的一个对象,所以试试这个:
entity.label= new Cesium.LabelGraphics({
position : Cesium.Cartesian3.fromDegrees(-75.1641667, 39.9522222),
text : 'Philadelphia',
font : '24px Helvetica',
fillColor : Cesium.Color.SKYBLUE,
outlineColor : Cesium.Color.BLACK,
outlineWidth : 2,
})
隐藏它使用
enity.label.show=false;
关于javascript - 在 Cesium 中为多边形添加标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45077010/