cesium添加集合对象,分别用entity和primitive的方式实现,只设置部分参数作为示例,其他详细参数请自行查阅api。
1、point
// point entity方式 add参数具体见Cesium.PointGraphics
viewer.entities.add({
name: "point",
position: Cesium.Cartesian3.fromDegrees(113.396241, 38.090767, 0.5),
point: {
color: Cesium.Color.fromCssColorString("#ff0000"),
pixelSize: 10,
outlineColor: Cesium.Color.fromCssColorString("#ffffff"),
outlineWidth: 2,
},
});
// point primitive方式 add参数具体见Cesium.PointPrimitive
let ppc = viewer.scene.primitives.add(new Cesium.PointPrimitiveCollection());
ppc.add({
position: Cesium.Cartesian3.fromDegrees(113.3963, 38.090769),
color: Cesium.Color.RED
});
// point primitive 以一个点为原点,其他点为相对位置的方式 add参数具体见Cesium.PointPrimitive
let ppc2 = viewer.scene.primitives.add(new Cesium.PointPrimitiveCollection());
let center = Cesium.Cartesian3.fromDegrees(113.3963, 38.090769);
ppc2.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(center);
ppc2.add({
position: new Cesium.Cartesian3(10, 10),
color: Cesium.Color.GREEN
});
2、label
// label entity方式 add参数具体见Cesium.LabelGraphics
viewer.entities.add({
name: "label",
position: Cesium.Cartesian3.fromDegrees(113.196216, 38.19071, 0.5),
label: {
text: 'label',
fillColor: Cesium.Color.fromCssColorString("#ff0000"),
outlineColor: Cesium.Color.fromCssColorString("#ffffff"),
outlineWidth: 2,
},
});
// label primitive方式 add参数具体见Cesium.Label
let lc = viewer.scene.primitives.add(new Cesium.LabelCollection());
lc.add({
position: Cesium.Cartesian3.fromDegrees(113.396299, 38.09071),
text: 'label',
});