Cesium截屏

1.实现cesium截屏功能,有时候截屏中没有cesium里面的要素,需要在地球初始化options里面配置如下代码

 "contextOptions": {
      "webgl": {
        "alpha": true,
        "depth": false,
        "stencil": true,
        "antialias": true,
        "premultipliedAlpha": true,
        "preserveDrawingBuffer": true,
        "failIfMajorPerformanceCaveat": true
      },
      "allowTextureFilterAnisotropic": true
    }

2.截屏功能可以使用插件html2canvas 安装后使用方法如下

exportMap () {
      const mapDom = document.getElementById('allElement')
      html2canvas(mapDom, {
        backgroundColor: null,
        useCORS: true, // 如果截图的内容里有图片,可能会有跨域的情况,加上这个参数,解决文件跨域问题
        logging: false // 日志开关,便于查看html2canvas的内部执行流程
      }).then(canvas => {
        document.body.appendChild(canvas)
        console.log(canvas.toDataURL())
        canvas.toBlob(blob => {
          // 以时间戳作为文件名 实时区分不同文件 按需求自己定义就好
          const filename = `${new Date().getTime()}.jpg`
          // 转换canvas图片数据格式为formData
          const file2 = new File([blob], filename, { type: 'image/jpg' })
          console.log(file2)
        })
      })
    },
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值