当前位置:网站首页>Cesium Click to obtain longitude and latitude (2D coordinates)
Cesium Click to obtain longitude and latitude (2D coordinates)
2022-06-28 02:09:00 【The most ferocious little seal】
The following code applies to Two dimensional coordinates , Obtain the longitude and latitude coordinates of the ellipsoid surface .
handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(event => {
// Screen coordinates are converted to spatial coordinates
let cartesian = viewer.camera.pickEllipsoid(event.position, viewer.scene.globe.ellipsoid);
if (cartesian == undefined) {
console.log(' No coordinates obtained ')
} else {
// 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
console.log(' Longitude and latitude are :', {
x: lon, y: lat });
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK)
Cancel the left click event
handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK)
Be careful : pickEllipsoid There is a certain error when loading the terrain , The more concave and convex the terrain is , The greater the error , Therefore, the above aspects can only be used for Two dimensional coordinates Acquisition .
See my other article on 3D coordinates
边栏推荐
- Supervised, unsupervised and semi supervised learning
- 【嵌入式基础】内存(Cache,RAM,ROM,Flash)
- JS 数组随机取值(随机数组取值)
- centos8-操作记录-命令版-yum-redis-mysql-nacos-jdk
- The interviewer asked: this point of JS
- What are the risks of opening a compass stock account? Is it safe to open a compass account
- Centos8 operation record command version Yum redis MySQL Nacos JDK
- 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
- COSCon'22 讲师征集令
- Capacitor
猜你喜欢

Adobe Premiere Basics - general operations for editing material files (offline files, replacing materials, material labels and grouping, material enabling, convenient adjustment of opacity, project pa

药物发现综述-01-药物发现概述

Evaluation - rank sum ratio comprehensive evaluation

Adobe Premiere Basics - common video effects (cropping, black and white, clip speed, mirroring, lens halo) (XV)

Cesium 点击绘制多边形(动态绘制多边形)

Self supervised learning and drug discovery

1382. 将二叉搜索树变平衡-常规方法

Intranet penetration with FRP

The practice of dual process guard and keeping alive in IM instant messaging development

Evaluation - grey correlation analysis
随机推荐
Set collection usage
Adobe Premiere基础-常用的视频特效(边角定位,马赛克,模糊,锐化,手写工具,效果控件层级顺序)(十六)
The interviewer asked: this point of JS
对比学习中的4种经典训练模式
What problems should be evaluated before implementing MES management system
Prometeus 2.35.0 new features
[Yocto RM]3 - Yocto Project Releases and the Stable Release Process
OS模块与OS.path 模块的学习
TIA botu_ Concrete method of making analog input and output Global Library Based on SCL language
类的初始化与回调的用法
深入解析kubernetes controller-runtime
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)
Machine learning notes - time series as features
[embedded foundation] serial port communication
I/o limit process and CPU limit process
Review of drug discovery-03-molecular design and optimization
机器学习笔记 - 时间序列作为特征
[Yocto RM]1 - System Requirements
Arrays. Aslist() pit