当前位置:网站首页>Click cesium to obtain three-dimensional coordinates (longitude, latitude and elevation)
Click cesium to obtain three-dimensional coordinates (longitude, latitude and elevation)
2022-07-03 06:08:00 【The most ferocious little seal】
The following code applies to Get the terrain surface Three dimensional coordinates .
Be careful :
- It is applicable to picking points with terrain elevation
- Not applicable to model 、 Tilt photography and other surface heights ( Please read my other article )
- Depth detection needs to be turned on
depthTestAgainstTerrain = true.
// Open depth detection
viewer.scene.globe.depthTestAgainstTerrain = true
var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(function (evt) {
// Return to one ray And an intersection of the earth's surface Cartesian3 coordinate .
let ray = viewer.camera.getPickRay(evt.position);
let cartesian = viewer.scene.globe.pick(ray, viewer.scene);
// // Space coordinates to world coordinates ( radian )
let cartographic = Cesium.Cartographic.fromCartesian(cartesian);
// Radian to angle ( Longitude and latitude )
let lon = Cesium.Math.toDegrees(cartographic.longitude); // Longitude value
let lat = Cesium.Math.toDegrees(cartographic.latitude); // Latitude value
// Terrain height ( Just choose one of the following two )
let height = cartographic.height;
let height2 = viewer.scene.globe.getHeight(cartographic)
console.log(' The longitude and latitude elevation is :', {
x: lon, y: lat, height: height, height2: height2 })
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
Cancel the left click event
handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK)

Elevation part :cartographic.height and viewer.scene.globe.getHeight(cartographic) These two are elevations , You can see from the above figure that , There are some subtle differences , But it doesn't matter , You can use either of these two .
边栏推荐
- Kubernetes notes (II) pod usage notes
- 智牛股项目--04
- Kubernetes notes (VIII) kubernetes security
- Phpstudy setting items can be accessed by other computers on the LAN
- If function of MySQL
- Synthetic keyword and NBAC mechanism
- Kubesphere - build MySQL master-slave replication structure
- Characteristics and isolation level of database
- Oauth2.0 - user defined mode authorization - SMS verification code login
- Leetcode solution - 02 Add Two Numbers
猜你喜欢
![[Zhao Yuqiang] deploy kubernetes cluster with binary package](/img/cc/5509b62756dddc6e5d4facbc6a7c5f.jpg)
[Zhao Yuqiang] deploy kubernetes cluster with binary package

Kubernetes notes (III) controller
![[teacher Zhao Yuqiang] redis's slow query log](/img/a7/2140744ebad9f1dc0a609254cc618e.jpg)
[teacher Zhao Yuqiang] redis's slow query log

Understand one-way hash function

How does win7 solve the problem that telnet is not an internal or external command

Clickhouse learning notes (2): execution plan, table creation optimization, syntax optimization rules, query optimization, data consistency

Multithreading and high concurrency (7) -- from reentrantlock to AQS source code (20000 words, one understanding AQS)

项目总结--01(接口的增删改查;多线程的使用)

Kubernetes notes (VI) kubernetes storage

【系统设计】邻近服务
随机推荐
1. 两数之和
[teacher Zhao Yuqiang] use the catalog database of Oracle
CAD插件的安装和自动加载dll、arx
Fluentd facile à utiliser avec le marché des plug - ins rainbond pour une collecte de journaux plus rapide
88. Merge two ordered arrays
Ext4 vs XFS -- which file system should you use
70 shell script interview questions and answers
Strategy pattern: encapsulate changes and respond flexibly to changes in requirements
Zhiniu stock -- 03
The server data is all gone! Thinking caused by a RAID5 crash
What's the difference between using the Service Worker Cache API and regular browser cache?
Kubesphere - build Nacos cluster
JS implements the problem of closing the current child window and refreshing the parent window
Jedis source code analysis (II): jediscluster module source code analysis
Kubesphere - build MySQL master-slave replication structure
轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
Oauth2.0 - explanation of simplified mode, password mode and client mode
Download the corresponding version of chromedriver
ThreadLocal的简单理解
【系统设计】邻近服务