| | |
| | | let me_longitude = 0; |
| | | let me_altitude = 0; |
| | | // 扫射定位 |
| | | let measure_target_longitude = 0; |
| | | let measure_target_latitude = 0; |
| | | let measure_target_altitude = 0; |
| | | let measure_target_longitude = 115.85635872364763; |
| | | let measure_target_latitude = 28.624648387113627; |
| | | let measure_target_altitude = 63.5; |
| | | |
| | | |
| | | async function initDock(data:any, sn:any, dockSn:any, workspaceId:any, ssLinePath:any, viewDroneInfo:any) { |
| | |
| | | // 获取手机定位和激光发射定位的高度和距离 |
| | | function getTwoHeightWidth(workspaceId:String) { |
| | | // 国内地图不会为0或者小于0 |
| | | console.log('自身定位经纬度1', me_latitude) |
| | | console.log('自身定位经纬度2', me_longitude) |
| | | console.log('激光扫过定位1', measure_target_latitude) |
| | | console.log('激光扫过定位2', measure_target_longitude) |
| | | // console.log('自身定位经纬度1', me_latitude) |
| | | // console.log('自身定位经纬度2', me_longitude) |
| | | // console.log('激光扫过定位1', measure_target_latitude) |
| | | // console.log('激光扫过定位2', measure_target_longitude) |
| | | if (me_latitude <= 0 || me_longitude <= 0 || measure_target_latitude <= 0 || measure_target_longitude <= 0) return |
| | | getTwoPointInfo(workspaceId,me_latitude,me_longitude,measure_target_latitude,measure_target_longitude).then((res:any) => { |
| | | const heightDifference = res.data.heightDifference |
| | |
| | | |
| | | const meMapSrc = new URL('@/assets/images/me.png', import.meta.url).href |
| | | // 获取手机设备定位 |
| | | function getPhoneLocation(value:Boolean, workspaceId:String) { |
| | | function getPhoneLocation(workspaceId:String) { |
| | | if (window.cesiumViewer == null) return |
| | | // 创建一个箭头实体 |
| | | removeById('me_dw') |
| | | myAppEntity = window.cesiumViewer.entities.add({ |
| | | id: 'me_dw', |
| | | position: globalCesium.Cartesian3.fromDegrees(0, 0, 0), // 初始位置 |
| | | billboard: { |
| | | image: meMapSrc, // 箭头图片路径 |
| | | width: 30, |
| | | height: 30, |
| | | alignedAxis: globalCesium.Cartesian3.UNIT_Z, // 对齐轴 |
| | | }, |
| | | // orientation: new globalCesium.CallbackProperty(() => { |
| | | // return globalCesium.Transforms.headingPitchRollQuaternion( |
| | | // myAppEntity.position.getValue(window.cesiumViewer.clock.currentTime), |
| | | // new globalCesium.HeadingPitchRoll(heading, 0, 0) // 设置朝向 |
| | | // ); |
| | | // }, false), |
| | | }); |
| | | |
| | | let heading = 0; // 初始朝向 |
| | | // 获取设备朝向 |
| | | // if (window.DeviceOrientationEvent) { |
| | | // window.addEventListener('deviceorientation', (event) => { |
| | | // if (event.alpha !== null) { |
| | | // heading = globalCesium.Math.toRadians(event.alpha); // 将 alpha 转换为弧度 |
| | | // } |
| | | // }); |
| | | // } else { |
| | | // console.log('手机不支持.'); |
| | | // } |
| | | |
| | | // 获取设备位置 |
| | | if (navigator.geolocation) { |
| | | navigator.geolocation.watchPosition((position) => { |
| | | if (me_longitude > 0 && me_longitude == position.coords.longitude && me_latitude > 0 && me_latitude == position.coords.latitude) return |
| | | me_longitude = position.coords.longitude; |
| | | me_latitude = position.coords.latitude; |
| | | me_altitude = position.coords.altitude || 0; |
| | | |
| | | // 更新箭头实体的位置 |
| | | myAppEntity.position = globalCesium.Cartesian3.fromDegrees(me_longitude, me_latitude, me_altitude); |
| | | if (value) { |
| | | // 将相机定位到设备位置 只有点击图标才可以执行这里 |
| | | window.cesiumViewer.camera.setView({ |
| | | destination: globalCesium.Cartesian3.fromDegrees(me_longitude, me_latitude, me_altitude + 1000), // 相机高度 |
| | | // orientation: { |
| | | // heading: heading, // 相机朝向 |
| | | // pitch: globalCesium.Math.toRadians(-90), // 俯视角度 |
| | | // roll: 0, |
| | | // }, |
| | | }); |
| | | } |
| | | // 创建一个箭头实体 |
| | | removeById('me_dw') |
| | | myAppEntity = window.cesiumViewer.entities.add({ |
| | | id: 'me_dw', |
| | | position: globalCesium.Cartesian3.fromDegrees(me_longitude, me_latitude, me_altitude), |
| | | billboard: { |
| | | image: meMapSrc, // 箭头图片路径 |
| | | width: 30, |
| | | height: 30, |
| | | scale: 1.0, |
| | | } |
| | | }); |
| | | // 查看两条线直接距离和高度 |
| | | getTwoHeightWidth(workspaceId) |
| | | }, (error) => { |
| | |
| | | } |
| | | } |
| | | |
| | | // 点击右边定自身定位 |
| | | function clickPhoneLocation() { |
| | | if (myAppEntity && myAppEntity != null) { |
| | | // 将相机定位到设备位置 只有点击图标才可以执行这里 |
| | | window.cesiumViewer.camera.setView({ |
| | | destination: globalCesium.Cartesian3.fromDegrees( |
| | | Number(me_longitude), |
| | | Number(me_latitude), |
| | | 10000.0, |
| | | ), // 相机高度 |
| | | }); |
| | | } |
| | | } |
| | | |
| | | |
| | | return { |
| | | initDock, |
| | | getPhoneLocation, |
| | | clickPhoneLocation |
| | | } |
| | | } |