当前位置: 首页 > news >正文

cesium实现区域贴图及加载多个gif动图

       1、cesium加载多个gif动图

        Cesium的Billboard支持单帧纹理贴图,如果能够将gif动图进行解析,获得时间序列对应的每帧图片,然后按照时间序列动态更新Billboard的纹理,即可实现动图纹理效果。为此也找到了相对于好一点的第三方库libgif能够将gif转化为一帧帧图像,正好能够满足我们的需求!!!

let gifImgList = [];data?.forEach((tag) => {let url = huangren;let gifDiv = document.createElement("div");let gifImg = document.createElement("img");// gif库需要img标签配置下面两个属性gifImg.setAttribute("rel:animated_src", url);gifImg.setAttribute("rel:auto_play", "1"); // 设置自动播放属性gifDiv.appendChild(gifImg);let superGif = new SuperGif({gif: gifImg,});gifImgList.push(superGif);});data?.forEach((tag, ind) => {gifImgList[ind].load(function () {onViewer.entities.add({_content: tag,position: new Cesium.Cartesian3.fromDegrees(Number(tag.longitude),Number(tag.latitude),100),billboard: {//图标image: new Cesium.CallbackProperty(() => {// 转成base64,直接加canvas理论上是可以的,这里设置有问题return gifImgList[ind].get_canvas().toDataURL();}, false),scale: 0.25,// width: 36,// height: 36,//sizeInMeters: true,//以米为单位,近大远小//pixelOffset: new Cesium.Cartesian2(0,20), //设置左右、上下移动//rotation:1.58, //设置旋转角度//scaleByDistance: new Cesium.NearFarScalar(20000,1,8000000, 0.1), //设置近大远小//pixelOffsetScaleByDistance: new Cesium.NearFarScalar(20000,10,8000000,100), //设置偏移量// translucencyByDistance:new Cesium.NearFarScalar(20000,1,8000000,0), //设置透明// distanceDisplayCondition: new Cesium.DistanceDisplayCondition(//   20000,//   8000000// ), //限制区域显示与隐藏//水平方向heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,// 垂直方向verticalOrigin: Cesium.VerticalOrigin.BASELINE,},});});});

2、cesium加载geoJSON并贴图

const dataSource = new Cesium.GeoJsonDataSource();dataSource.load("https://geo.datav.aliyun.com/areas_v3/bound/110000.json", {clampToGround: true,}).then(() => {onViewer.dataSources.add(dataSource);const entities = dataSource.entities.values;for (let i = 0; i < entities.length; i++) {const entity = entities[i];// 修改 entity 样式entity.polygon.material = new Cesium.ImageMaterialProperty({image: beijin,});entity.polygon.outline = false;// 添加 entity 的 polylineentity.polyline = {positions: entity.polygon.hierarchy._value.positions,width: 2,material: Cesium.Color.fromCssColorString("#ffff"),clampToGround: true,};// 获取一个 entity 的中心位置const center = Cesium.BoundingSphere.fromPoints(entity.polygon.hierarchy._value.positions).center;// 设置中心位置entity.position = center;// 添加 textentity.label = {text: entity.properties.name,color: Cesium.Color.fromCssColorString("#fff"),font: "normal 32px MicroSoft YaHei",showBackground: true,scale: 0.5,horizontalOrigin: Cesium.HorizontalOrigin.LEFT_CLICK,verticalOrigin: Cesium.VerticalOrigin.BOTTOM,disableDepthTestDistance: 10000.0,};}// if (zoomto) {onViewer.zoomTo(dataSource);// }});return dataSource;

http://www.lryc.cn/news/268265.html

相关文章:

  • blackbox黑盒监控部署(k8s内)tensuns专用
  • “C语言“——scanf()、getchar() 、putchar()、之间的关系
  • Spring Boot3 Web开发技术
  • 学习笔记:数据挖掘与机器学习
  • highcharts的甘特图设置滚动时表头固定,让其他内容跟随滚动
  • ElasticSearch 架构设计
  • HTML---定位
  • JVM高频面试题(2023最新版)
  • webpack学习-7.创建库
  • MQTT - 笔记
  • Django 安装
  • 推荐一个vscode看着比较舒服的主题:Dark High Contrast
  • YCSB 测试表预分区
  • K8s 教程
  • python:改进型鳟海鞘算法(SSALEO)求解23个基本函数
  • Hive-数据模型详解(超详细)
  • docker的常规使用总结
  • CSS 文字弹跳效果
  • 什么是动态IP?静态IP和动态IP有什么区别?
  • Linux 与 Shell
  • 大数据-Hive练习-环比增长率、同比增长率、复合增长率
  • C++ 考前难点总结
  • ARM 汇编语言知识积累
  • k8s面试之——简述网络模型
  • C语言中关于if else的理解
  • Keil5软件仿真 定时器互补通道 波形输出(Logic Analyzer)
  • 华纳云:怎么实现Linux主机ssh无密码登录
  • 模型树实操
  • html table+css实现可编辑表格
  • c语言:计算1+2+3……+n的和|练习题