let startPoint = this.viewer.entities.add( //viewer.entities.add 添加實體的方法
{
name: '測量距離', //這個屬性跟頁面顯示的內容沒有關系,只是一個屬性 position: this.Cesium.Cartesian3.fromDegress(longitude, latitude, height), point: { //表示點 heightReference: this.Cesium.HeightReference.CLAMP_TO_GROUND, color: this.Cesium.Color.WHITE, //點的顏色 pixelSize: 6, //點的大小 outlineColor: this.Cesium.Color.RED, //就是所謂的border-color outlineWidth: 2 //border-width }, label: { //表示點的描述 text: "起點", //點的文字 font: '14pt Source Han Sans CN', //文字的大小和字體 fillColor: _this.Cesium.Color.RED, //文字的顏色
注意,這里的this.Cesium.Color后面只能接顏色的英文,不能接十六進制的顏色
如果你需要用到十六進制的顏色,可以使用這樣來表示:
fillColor: this.Cesium.Color.fromCssColorString('#f00')
backgroundColor: _this.Cesium.Color.AQUA, //給文字添加背景顏色
showBackground: true, //若是想給文字添加背景顏色 這行必不可少
style: this.Cesium.LabelStyle.FILL_AND_OUTLINE,
outlineWidth: 3, //垂直位置 heightReference: this.Cesium.HeightReference.NONE, verticalOrigin: this.Cesium.VerticalOrigin.TOP, pixelOffset: new this.Cesium.Cartesian2(0, 10) //偏移度 0 表示x軸上的偏移量 10表示y軸上的偏移量 } } )
( 我這里用this.Cesium 是因為我配置了Cesuim的全局變量,如果沒有配置的就直接Cesium.就可以 )