Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cesium 获取当前相机位置 #862

Open
klren0312 opened this issue Nov 11, 2024 · 0 comments
Open

cesium 获取当前相机位置 #862

klren0312 opened this issue Nov 11, 2024 · 0 comments
Labels
Gis JS js相关问题

Comments

@klren0312
Copy link
Owner

function getcameraPosInfo(){
  // 获取 相机姿态信息
  const head = viewer.scene.camera.heading 
  const pitch = viewer.scene.camera.pitch
  const roll  = viewer.scene.camera.roll
  const info ={'head': head ,'pitch': pitch ,'roll': roll};
  // 获取位置 wgs84的地心坐标系,x,y坐标值以弧度来表示
  const position = viewer.scene.camera.positionCartographic //with longitude and latitude expressed in radians and height in meters.

  // 弧度转经纬度
  const longitude = Cesium.Math.toDegrees(position.longitude).toFixed(6)
  const latitude =  Cesium.Math.toDegrees(position.latitude).toFixed(6)
  const height = position.height
  console.log({
    lng: longitude,
    lat:latitude,
    h:height,
    mat:info
  })
}
@klren0312 klren0312 added JS js相关问题 Gis labels Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gis JS js相关问题
Projects
None yet
Development

No branches or pull requests

1 participant