当前位置:网站首页>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 在加载地形的情况下有一定误差,地形凹凸程度越大,误差越大,所以上述方面只能用于 二维坐标 的获取。
三维坐标请看我的另一篇文章
边栏推荐
- Google Earth engine (GEE) -- an error caused by the imagecollection (error) traversing the image collection
- Numpy----np.tile()函数解析
- Lefse analyzes the local implementation method with all installation files and details to ensure success.
- TI AM3352/54/59 工业核心板硬件说明书
- I/o limit process and CPU limit process
- Arrays.asList()坑
- Database query optimization: master-slave read-write separation and common problems
- 【牛客讨论区】第四章:Redis
- Comprehensive evaluation of free, easy-to-use and powerful open source note taking software
- 9. Openfeign service interface call
猜你喜欢

What is digitalization? What is digital transformation? Why do enterprises choose digital transformation?

Lmsoc: a socially sensitive pre training method

Maimai hot post: Why are big factories keen on making wheels?

MapReduce elementary programming practice

Numpy----np.reshape()

【嵌入式基础】内存(Cache,RAM,ROM,Flash)

【嵌入式基础】串口通信

1382. balancing binary search tree - General method

零基礎多圖詳解圖神經網絡
![[embedded foundation] serial port communication](/img/b7/18fec20e2d5fa5f226c6f8bb1e93d2.png)
[embedded foundation] serial port communication
随机推荐
【牛客讨论区】第四章:Redis
Database query optimization: master-slave read-write separation and common problems
frp实现内网穿透
药物发现综述-02-分子性质预测
style中的scoped属性和lang属性
Neural network of zero basis multi map detailed map
树莓派实现温控风扇智能降温
fiddle如何使用代理
Review of drug discovery-02-prediction of molecular properties
【牛客討論區】第四章:Redis
Set collection usage
[Niuke discussion area] Chapter 4: redis
Solve storage problems? WMS warehouse management system solution
Can you open an account for stock trading in flush? Is it safe?
Original | 2025 to achieve the "five ones" goal! The four products of Jiefang power are officially released
零基础多图详解图神经网络
力扣今日题-522. 最长特殊序列
模块化开发
PV操作原语
要搞清楚什么是同步,异步,串行,并行,并发,进程,线程,协程