cesium 使用 GeoJsonDataSource 加载 geoJson 数据,渲染 Polygon、polyline、Text 贴地配置
2023-09-11 14:16:38 时间
原文地址:https://juejin.cn/post/7029592051154944007
export function renderPolygon(geojson: any, zoomto: Boolean = true) { const viewer = window.viewer const dataSource = new Cesium.GeoJsonDataSource() // [cesium加载geoJson数据] https://juejin.cn/post/7029592051154944007 dataSource.load(geojson, { clampToGround: true }).then(() => { viewer.dataSources.add(dataSource) const entities = dataSource.entities.values for (let i = 0; i < entities.length; i++) { const entity = entities[i] // 修改 entity 样式 entity.polygon.material = Cesium.Color.fromCssColorString('#ff0000').withAlpha(0.5) // 添加 entity 的 polyline entity.polyline = { positions: entity.polygon.hierarchy._value.positions, width: 2, material: Cesium.Color.fromCssColorString('#ffff00') } // 获取一个 entity 的中心位置 const center = Cesium.BoundingSphere.fromPoints(entity.polygon.hierarchy._value.positions).center // 设置中心位置 entity.position = center // 添加 text entity.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) { viewer.zoomTo(dataSource) } }) return dataSource }
相关文章
- 大数据开发keras框架环境配置小结
- Mybatis+mysql动态分页查询数据案例——配置映射文件(HouseDaoMapper.xml)
- Mybatis+mysql动态分页查询数据案例——配置映射文件(HouseDaoMapper.xml)
- 大数据应用日志采集之Scribe 安装配置指南
- Redis学习(1)--环境配置,安装JDK,MySQL,tomcat
- web.xml配置web中的key points(下)
- 大数据是否有可能有效配置资源?
- centos8上redis5在生产环境的配置
- 服务器搭建:手把手教你配置web服务之nginx1.6
- 根据XML配置规则导入Excel数据(五)ExcelReader XLS解析类
- [ASP.NET Core 3框架揭秘] 配置[5]:配置数据与数据源的实时同步
- SAP Marketing Cloud Contact 模型的导入配置和数据合并原理
- 【项目实战】spring-boot-configuration-processor 一个用于生成配置元数据的注解处理器
- 防火墙配置了IPsec之后,数据到达防火墙上明明匹配了对应的安全策略但是却没有任何数据转发出去
- 成功解决IDEA中建立新项目Maven会默认选择配置(图解详细说明)
- 如何配置svn服务器
- Nginx反向代理,负载均衡配置
- 45.第十章 网络协议和管理配置 -- TCP/IP 协议栈(六)
- 龙芯软件开发(35)- USB协议深入分析 设备描述符配置包
- kibana智能检索发送多次_msearch —— 配置index pattern,同时设置时间段,就知道到底是在哪些索引里去查找数据了
- RFSoC应用笔记 - RF数据转换器 -20- API使用指南之配置RFDC工作状态(ADC、DAC均适用)
- RFSoC应用笔记 - RF数据转换器 -12- RFSoC关键配置之其他功能(三)
- RFSoC应用笔记 - RF数据转换器 -08- RFSoC关键配置之RF-DAC内部解析(二)
- CentOS6安装大数据软件(五):Flume安装与配置
- Win10系统下VisualStudio2019配置PDAL库
- 【云原生 | Kubernetes 系列】---altermanager消息配置和pushgateway
- RTX30系列linux+docker容器的GPU配置(tensorflow-gpu==1.15~2.x、tensorrt 7、cuda、cudnn)附加resnet50模型测试