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

Cesium 问题:加载 geojson 数据量大浏览器会崩,使用primitive方式加载

文章目录

    • 问题
    • 分析

问题

之前加载geojson数据都是使用dataSource和entity的方式,但是当数据量大时,浏览器就会崩掉:提示浏览器内存不足,已暂停渲染

分析

使用primitive方式加载数据,可以提高加载渲染效率。实现方法如下:

getServePyApi(tempData).then((res)=>{if(res){var contents = res.data.result;console.log(res);const instances = [];let features = contents.features;for (let i = 0; i < features.length; i++) {for (let j = 0; j < features[i].geometry.coordinates.length; j++) {const polygonArray = features[i].geometry.coordinates[j].toString().split(',');const polygon = new Cesium.PolygonGeometry({polygonHierarchy: new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArray(polygonArray)),// 设置面的拉伸高度extrudedHeight: 35,});var count = features[i].properties.index_coun;const color = null; // 根据 count 值设置不同的颜色if (count >= 0 && count < 10) {color = Cesium.Color.fromCssColorString('#FF0000');  // 设置红色} else if (count >= 10 && count < 20) {color = Cesium.Color.fromCssColorString('#00FF00');  // 设置绿色} else {color = Cesium.Color.fromCssColorString('#0000FF');  // 设置蓝色}const geometry = Cesium.PolygonGeometry.createGeometry(polygon);instances.push(new Cesium.GeometryInstance({geometry: geometry,attributes: {color: Cesium.ColorGeometryInstanceAttribute.fromColor(color),},}));}}// 合并单个geometry,提高渲染效率this.od5 = new Cesium.Primitive({geometryInstances: instances,appearance: new Cesium.PerInstanceColorAppearance(),});window.viewer.scene.primitives.add(this.od5);});
http://www.lryc.cn/news/176351.html

相关文章:

  • C++ Primer----1.5类简介 章节练习
  • 爬楼梯Java(斐波那契数列)
  • Maven项目package为jar包后在window运行报A JNI error has occurred
  • iview 的table表格组件使单元格可编辑和输入
  • 统计的基本概念及抽样分布
  • 【C++】class的设计与使用(四)this指针
  • mysql 导入sql文件
  • springcloud:三、ribbon负载均衡原理+调整策略+饥饿加载
  • 【Unity编辑器扩展】Tranform组件自定义扩展,复制位置旋转缩放数据
  • 自动驾驶领域中的CMS系统应用探讨
  • 十分钟理解OSPF路由协议
  • Python 编程基础 | 第一章-预备知识 | 1.4、包管理工具
  • delphi中使用CADVCL 10.0 Enterprise控件解析DXF文件生成图片保存到本地
  • Hazelcast系列(三):hazelcast管理中心
  • QT 绘画功能的时钟
  • 设计模式之道-模板方法模式
  • 头哥的实践平台的Linux文件/目录管理
  • 软件测试基本常识
  • Xmake v2.8.3 发布,改进 Wasm 并支持 Xmake 源码调试
  • Serverless 数仓技术与挑战(内含 PPT 下载)
  • 九牧小牧携手国家队!一场“中国卫浴“和“中国体育”的双向奔赴
  • crypto:Quoted-printable
  • 【六级】作文模板-议论文-问题解决
  • leetcodetop100 (22) 反转链表
  • RabbitMQ配置文件_修改RabbitMQ MQTT的1883端口
  • 【Graph Net学习】LINE实现Graph Embedding
  • docker安装使用xdebug
  • (1) ESP32获取图像,并通过电脑端服务器显示图像
  • 乐鑫科技全球首批支持蓝牙 Mesh Protocol 1.1 协议
  • 1.算法——数据结构学习