Cesium 贴地属性设置

一、 Entity实体贴地

大部分entity 实体是有 heightReference 参数的,可以通过 heightReference: Cesium.HeightReference.CLAMP_TO_GROUND 设置贴地

viewer.entities.add({
    
    
// fromDegrees(经度,纬度,高度,椭球,结果)从以度为单位的经度和纬度值返回Cartesian3位置
  position: Cesium.Cartesian3.fromDegrees(108, 34, 10),
  point: {
    
    
    color: Cesium.Color.fromCssColorString('#ee0000'),
    heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,  //设置 HeightReference 高度参考类型为 CLAMP_TO_GROUND 贴地类型
  }
});

二、polyline

虽然polyline也是entity,但是它是通过设置 clampToGround: true 来设置贴地

viewer.entities.add({
    
    
  polyline: {
    
    
    positions: Cesium.Cartesian3.fromDegreesArray([
      120.9677706, 30.7985748,
      110.20, 34.55
    ]),
    // 宽度
    width: 2,
    // 线的颜色
    material: Cesium.Color.WHITE,
    clampToGround: true,	// 设置 clampToGround 为 true,实现贴地
  }
});

三、GEOJSON,KML,CZML

都是通过设置 clampToGround: true 来设置贴地

Cesium.GeoJsonDataSource.load(URL,
{
    
    
  stroke: Cesium.Color.fromCssColorString("#27E31E"),   // 边框颜色
  strokeWidth: 5, // 边框宽度
  clampToGround: true,  // 贴地
})

猜你喜欢

转载自blog.csdn.net/qq_17627195/article/details/129710576