Cesium czml创建目标

一次性加载

(method) DataSourceCollection.add(dataSource: Cesium.DataSource | Promise<Cesium.DataSource>): Promise<Cesium.DataSource>
const czml = [
  {
    id: "document",
    name: "CZML Point",
    version: "1.0",
    clock: {
      "interval": "2012-03-15T10:00:00Z/2012-03-15T18:00:00Z",
      "currentTime": "2012-03-15T10:00:00Z",
      "multiplier": 60,
      "range": "LOOP_STOP",
      "step": "SYSTEM_CLOCK_MULTIPLIER"
    }
  },
  {
    id: "point_1",
    name: "point",
    label: {
      fillColor: {
        rgba: [255, 255, 255, 255],
      },
      font: "13pt Lucida Console",
      horizontalOrigin: "LEFT",
      pixelOffset: {
        cartesian2: [20, 0],
      },
      style: "FILL",
      text: "referencing fillColor",
    },
    position: {
      "interpolationAlgorithm": "LAGRANGE",
      "interpolationDegree": 2,
      "referenceFrame": "INERTIAL",
      "epoch": "2012-03-15T10:00:00Z",
      cartographicDegrees: [
        0, .0, .0, 12742000,
        2000, 20.0, .0, 12742000,
        4000, 40.0, .0, 12742000,
        6000, 60.0, .0, 12742000,
        8000, 80.0, .0, 12742000,
        10000, 100.0, .0, 12742000,
        12000, 120.0, .0, 12742000,
        14000, 140.0, .0, 12742000,
        16000, 160.0, .0, 12742000,
        18000, 180.0, .0, 12742000,
      ],
    },
    point: {
      color: {
        rgba: [255, 255, 255, 255],
      },
      pixelSize: 5,
    },
    path: {
      "show": [
        {
          "interval": "2012-03-15T10:00:00Z/2012-03-15T15:00:00Z",
          "boolean": true
        }
      ],
      "width": 1,
      "material": {
        "solidColor": {
          "color": {
            "rgba": [
              255, 255, 255, 100
            ]
          }
        }
      },
      "resolution": 120,
      leadTime: 0,
      trailTime: 1e10
  }
];

const dataSourcePromise = Cesium.CzmlDataSource.load(czml)
viewer.dataSources.add(dataSourcePromise)
dataSourcePromise.then((dataSource) => {
  let point_1 = dataSource.entities.getById('point_1')
})

分段加载

可以通过CzmlDataSource.process实现分段加载

(method) CzmlDataSource.process(czml: Resource | string | any, options?: CzmlDataSource.LoadOptions): Promise<CzmlDataSource>
//创建并添加dataSource
const dataSource = new Cesium.CzmlDataSource();
viewer.dataSources.add(dataSource);
//保留dataSource原有数据,合并新数据
dataSource.process(czmlPath/part1.url)
dataSource.process(czmlPath/part2.url)

其中,part1应含有czml信息和完整的entity信息,part2包含czml信息和entity位置信息(和properties信息),proerties信息通过vehicleEntity.properties.fuel_remaining.getValue()方法获取,fuel_remainingproperties中的属性,定义为

"properties" : {
    "fuel_remaining" : {
        "epoch":"2012-08-04T16:00:00Z",
        "number": [
            3000, 19.9
        ]
    }
},
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值