cesium timeline时间改为系统时间(北京时间) vue版本

效果图:

初始化三维球后,追加如下代码

// 修改timeline时间  从珠联时间改为北京时间
initGlobel(){
  // 省略初始化.....
  this.viewer.animation.viewModel.dateFormatter = this.DateTimeFormatter
  this.viewer.animation.viewModel.timeFormatter = this.TimeFormatter 
  this.viewer.timeline.makeLabel = this.DateTimeFormatter
},

  // Date formatting to a global form

DateTimeFormatter(datetime, viewModel, ignoredate) {
  var julianDT = new Cesium.JulianDate()
  Cesium.JulianDate.addHours(datetime, 8, julianDT)
  var gregorianDT = Cesium.JulianDate.toGregorianDate(julianDT)
  var objDT
  if (ignoredate)
    objDT = ''
  else {
    objDT = new Date(gregorianDT.year, gregorianDT.month - 1, gregorianDT.day)
    objDT = gregorianDT.year + '年' + objDT.toLocaleString('zh-cn', { month: 'short' }) + gregorianDT.day + '日'
    if (viewModel || gregorianDT.hour + gregorianDT.minute === 0)
      return objDT
    objDT += ' '
  }
  return objDT + Cesium.sprintf('%02d:%02d:%02d', gregorianDT.hour, gregorianDT.minute, gregorianDT.second)
},

TimeFormatter (time, viewModel) {
  return this.DateTimeFormatter(time, viewModel, true)
},

加上这段代码直接timeline直接就变成了需要的,暂未发现参考案例中的问题

参考链接:https://huangwang.github.io/2018/06/09/Cesium%E5%B0%8F%E9%83%A8%E4%BB%B6animation%E5%92%8Ctimeline%E7%9A%84%E7%B3%BB%E7%BB%9F%E6%97%B6%E9%97%B4%E6%98%BE%E7%A4%BA/

 

 

 

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值