有时候在这个圆球上获取精确的经度纬度还不容易,特别是高度
还好在cesium提供了接口,看
let selft = this;
const scene = this.viewer.scene;
var canvas = scene.canvas;
var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(movement) {
var cartesian = scene.camera.pickEllipsoid(movement.endPosition, ellipsoid);
var ellipsoid = scene.globe.ellipsoid;
if (cartesian) { //能获取,显示坐标
var cartographic = ellipsoid.cartesianToCartographic(cartesian);
var coords = '经度' + Cesium.Math.toDegrees(cartographic.longitude).toFixed(2) + ', ' + '纬度' + Cesium.Math.toDegrees(
cartographic.latitude).toFixed(2) + '高度 ' + Math.ceil(selft.viewer.camera.positionCartographic.height);
console.log(coords) ;
} else { //不能获取不显示
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);