鼠标移动获取经纬度
js
// 注册鼠标移动事件
viewer.canvas.addEventListener("mousemove", function (e) {
var cartesian = viewer.scene.camera.pickEllipsoid(e);
if (cartesian) {
// 转换为地理坐标系
var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
MouseInfo.longitude = Cesium.Math.toDegrees(cartographic.longitude);
MouseInfo.latitude = Cesium.Math.toDegrees(cartographic.latitude);
MouseInfo.height = Math.ceil(
viewer.scene.camera.positionCartographic.height
);
}
});