zoukankan      html  css  js  c++  java
  • 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)
            })
          })
        },
    
    

    本文转自 https://blog.csdn.net/wo_buzhidao/article/details/117729546?spm=1001.2014.3001.5502,如有侵权,请联系删除。

  • 相关阅读:
    例题
    经典模型
    定义
    洛谷p2564生日礼物andp2627修建草坪
    转自大佬的线段树
    c++String类
    随机数
    JVM知识点总结
    task5 模型融合 打卡
    task4 建模与调参 打卡
  • 原文地址:https://www.cnblogs.com/hustshu/p/15618027.html
Copyright © 2011-2022 走看看