前言

 缺少前置学习使用资料,请自行查阅:[https://blog.csdn.net/weixin_44402694/article/details/123110136](https://blog.csdn.net/weixin_44402694/article/details/123110136)以下示例使用到的公共静态资料,不建议下载,建议官网自行下载超图Build资源,示例所涉及图片会在示例使用到时提供出来。如有需要可下载:[https://download.csdn.net/download/weixin_44402694/82180350](https://download.csdn.net/download/weixin_44402694/82180350)。【坐标转换】世界坐标转经纬度。

使用

  • 效果

  • 核心代码

// 转换
function convertion1(x, y, z) {const ellipsoid = viewer.scene.globe.ellipsoidconst cartesian3 = new Cesium.Cartesian3(x, y, z)const cartographic = ellipsoid.cartesianToCartographic(cartesian3)const lat = Cesium.Math.toDegrees(cartographic.latitude)const lon = Cesium.Math.toDegrees(cartographic.longitude)const alt = cartographic.heightreturn {lon,lat,alt,}
}
  • 完整代码
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>坐标转换 - 世界坐标转经纬度</title><link href="./public/Build/Cesium/Widgets/widgets.css" rel="stylesheet" /><scripttype="text/javascript"src="./public/Build/Cesium/Cesium.js"></script><style>* {margin: 0;padding: 0;}html,body,#cesium-container {width: 100%;height: 100%;}.panel {width: 150px;position: fixed;left: 10px;top: 10px;z-index: 1;background-color: #fff;}.panel .btn {cursor: pointer;word-break: break-all;}.latlng-wrap {position: fixed;left: 200px;top: 10px;z-index: 1;background-color: #fff;display: flex;flex-direction: column;}.old {display: flex;flex-direction: row;}.old p {margin-right: 20px;}.new {display: flex;flex-direction: row;}.new p {margin-right: 20px;}.new p .result1 {color: red;}</style></head><body><div id="cesium-container" /><div class="panel"><p class="btn">点击转换</p></div><div class="latlng-wrap"><div class="old"><p>x:-2761814.335408733</p><p>y:4783602.750000001</p><p>z:3189068.4999999995</p></div><div class="new"><p><span>经度lon:</span><span class="result1"></span></p><p><span>纬度lat:</span><span class="result1"></span></p><p><span>高度:</span><span class="result1"></span></p></div></div><script>let viewerwindow.onload = function () {viewer = new Cesium.Viewer('cesium-container')initBindConversionEventHandler()}// 初始化绑定转换事件function initBindConversionEventHandler() {const btns = document.querySelectorAll('.panel .btn')btns[0].addEventListener('click', () => {const resultSpan = document.querySelectorAll('.result1')const { lon, lat, alt } = convertion1(-2761814.335408733,4783602.750000001,3189068.4999999995)resultSpan[0].innerHTML = lonresultSpan[1].innerHTML = latresultSpan[2].innerHTML = alt})}// 转换function convertion1(x, y, z) {const ellipsoid = viewer.scene.globe.ellipsoidconst cartesian3 = new Cesium.Cartesian3(x, y, z)const cartographic = ellipsoid.cartesianToCartographic(cartesian3)const lat = Cesium.Math.toDegrees(cartographic.latitude)const lon = Cesium.Math.toDegrees(cartographic.longitude)const alt = cartographic.heightreturn {lon,lat,alt,}}</script></body>
</html>

【超图+CESIUM】【基础API使用示例】28、超图|CESIUM -【坐标转换】世界坐标转经纬度相关推荐

  1. 【超图+CESIUM】【基础API使用示例】04、超图|CESIUM - 设置地图风格样式

    前言 缺少前置学习使用资料,请自行查阅:[https://blog.csdn.net/weixin_44402694/article/details/123110136](https://blog.c ...

  2. 【超图+CESIUM】【基础API使用示例】10、超图|CESIUM - 场景出图、下载当前截图

    前言 缺少前置学习使用资料,请自行查阅:[https://blog.csdn.net/weixin_44402694/article/details/123110136](https://blog.c ...

  3. 【超图+CESIUM】【基础API使用示例】42、超图|CESIUM - 绘制编辑线段|读取kml文件绘制编辑|导出kml线段数据

    前言 缺少前置学习使用资料,请自行查阅:[https://blog.csdn.net/weixin_44402694/article/details/123110136](https://blog.c ...

  4. 【超图+CESIUM】【基础API使用示例】38、超图|CESIUM - 特效-云层设置

    前言 缺少前置学习使用资料,请自行查阅:[https://blog.csdn.net/weixin_44402694/article/details/123110136](https://blog.c ...

  5. 【超图+CESIUM】【基础API使用示例】41、超图|CESIUM - 特效-雪景设置

    前言 缺少前置学习使用资料,请自行查阅:[https://blog.csdn.net/weixin_44402694/article/details/123110136](https://blog.c ...

  6. 【超图+CESIUM】【基础API使用示例】43、超图|CESIUM - 绘制编辑面|读取kml文件绘制编辑|导出kml面数据

    前言 缺少前置学习使用资料,请自行查阅:[https://blog.csdn.net/weixin_44402694/article/details/123110136](https://blog.c ...

  7. 【超图+CESIUM】【基础API使用示例】22、超图|CESIUM - 标绘面:Cesium.DrawHandler绘制面Cesium.DrawMode.Polygon

    前言 缺少前置学习使用资料,请自行查阅:[https://blog.csdn.net/weixin_44402694/article/details/123110136](https://blog.c ...

  8. 【超图+CESIUM】【基础API使用示例】16、超图|CESIUM -设置地球模式:椭球模式、圆球模式

    前言 缺少前置学习使用资料,请自行查阅:[https://blog.csdn.net/weixin_44402694/article/details/123110136](https://blog.c ...

  9. 【超图+CESIUM】【基础API使用示例】50、超图|CESIUM - moveLeft\moveRight\moveForward\moveBackward实现运动中的碰撞检测效果

    前言 由于项目业务需要,所以实现了这四个api的碰撞检测效果. 核心是通过ray射线来做碰撞检测. 代码目录结构 核心代码 <ul class="btn-list">& ...

  10. cesium米转换经纬度_cesium 常见坐标系及坐标转换(工具篇)

    /* * @Description: 坐标转换工具,下面的坐标转换默认都是基于WGS84 椭球体 */ class Degrees { constructor(longitude, latitude, ...

最新文章

  1. starrocks问题小结
  2. 使用命名管道的OVERLAPPED方式实现非阻塞模式编程 .
  3. zk和eureka的区别
  4. 【LeetCode】169. Majority Element
  5. Zabbix介绍及安装部署
  6. java ehcahce刷新_springboot结合ehcache防止恶意刷新请求的实现
  7. 可以进行单元测试么_前端与单元测试
  8. AUTOSAR从入门到精通100讲(二十八)-AutoSar之CAN网络管理
  9. C Primer Plus(三)
  10. 【Elasticsearch】在Elasticsearch中查询Term Vectors词条向量信息
  11. 设计模式之二-Proxy模式
  12. 小程序代理创业成功的五个条件
  13. 将数据追加到html 表格中,【HTML】使用Jquery实现将输入数据添加至表格中
  14. 微信小程序template模板使用
  15. 用Now SMS/MMS 发送中国移动彩信
  16. 寒门再难出贵子?学会这个方法,跨越阶层不是梦
  17. C++Primer 习题 第7章
  18. 温控仪C语言程序,模糊PID控制温控系统设计C语言程序代码
  19. Java的IO流---File类的使用
  20. python 抓取微博评论破亿_Python爬虫实战演练:爬取微博大V的评论数据

热门文章

  1. 研究生教育学科专业目录(2022年)与研究生教育学科专业目录管理办法
  2. 英语计算机简历模板,计算机研究生英文简历模板
  3. 青龙面板2.8 Ninja扫码安装教程(二)
  4. [TCL]Tcl语言基礎教程(一)
  5. luogu P4593 [TJOI2018]教科书般的亵渎
  6. 虚拟化的软件有哪些?区别是什么?
  7. ae万能弹性表达式_18种常用AE表达式解析【建议收藏】
  8. SpringBoot整合Selenium
  9. 日照科技中等专业学校 远程预付费系统的设计与应用
  10. 皮尔特沃夫服务器在什么位置,你知道LOL大区的服务器在哪吗?很有可能就在你家旁边...