当前位置:网站首页>Cesium 点击获取经纬度(二维坐标)
Cesium 点击获取经纬度(二维坐标)
2022-06-28 00:06:00 【最凶残的小海豹】
下面代码适用于 二维坐标
,获取椭球体表面的经纬度坐标。
handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(event => {
// 屏幕坐标转为空间坐标
let cartesian = viewer.camera.pickEllipsoid(event.position, viewer.scene.globe.ellipsoid);
if (cartesian == undefined) {
console.log('没有获取到坐标')
} else {
// 空间坐标转世界坐标(弧度)
let cartographic = Cesium.Cartographic.fromCartesian(cartesian);
// 弧度转为角度(经纬度)
let lon = Cesium.Math.toDegrees(cartographic.longitude); // 经度值
let lat = Cesium.Math.toDegrees(cartographic.latitude); // 纬度值
console.log('经纬度是:', {
x: lon, y: lat });
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK)
取消左键点击事件
handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK)
注意: pickEllipsoid
在加载地形的情况下有一定误差,地形凹凸程度越大,误差越大,所以上述方面只能用于 二维坐标
的获取。
三维坐标请看我的另一篇文章
边栏推荐
- Review of drug discovery-03-molecular design and optimization
- 利用redis bitmap实现人员在线情况监控
- Chapitre 4: redis
- 【sylixos】NEW_ Example of type 1 character drive
- Implementation of timed tasks in laravel framework
- [Yocto RM]1 - System Requirements
- Web3 technology initial experience and related learning materials
- MySQL十种锁,一篇文章带你全解析
- Comprehensive evaluation of free, easy-to-use and powerful open source note taking software
- [Yocto RM]9 - QA Error and Warning Messages
猜你喜欢
Adobe Premiere基础-编辑素材文件常规操作(脱机文件,替换素材,素材标签和编组,素材启用,便捷调节不透明度,项目打包)(十七)
1382. balancing binary search tree - General method
Machine learning notes - time series as features
什么是数字化?什么是数字化转型?为什么企业选择数字化转型?
The research group of Xuyong and duanwenhui of Tsinghua University has developed an efficient and accurate first principles electronic structure deep learning method and program
类的初始化与回调的用法
[Yongyi XY chair] trial experience
Adobe Premiere Basics - common video effects (cropping, black and white, clip speed, mirroring, lens halo) (XV)
Adobe Premiere Basics - common video effects (corner positioning, mosaic, blur, sharpen, handwriting tools, effect control hierarchy) (16)
【嵌入式基础】串口通信
随机推荐
要搞清楚什么是同步,异步,串行,并行,并发,进程,线程,协程
Solve storage problems? WMS warehouse management system solution
How to study efficiently
引用层reboot后的大体流程
LMSOC:一种对社会敏感的预训练方法
Numpy----np.meshgrid()
Xctf attack and defense world misc wage earner advanced zone
How to optimize the "message" list of IM
学习 pickle
解决ionic4 使用hammerjs手势 press 事件,页面无法滚动问题
Some problems in awk
Comprehensive evaluation of free, easy-to-use and powerful open source note taking software
fiddle如何使用代理
Deep parsing of kubernetes controller runtime
Supervised, unsupervised and semi supervised learning
PostgreSQL setting auto increment field
Data analysts too hot? Monthly income 3W? Tell you the true situation of this industry with data
I/o limit process and CPU limit process
向excel中导入mysql中的数据表
Want to open an account to buy stock, is it safe to open an account on the Internet?