| | |
| | | let measure_target_altitude = 0; |
| | | |
| | | |
| | | async function initDock(data:any, sn:any, dockSn:any, workspaceId:any, ssLinePath:any, viewDroneInfo:any) { |
| | | // console.log('globalCesium查看是', globalCesium) |
| | | async function initDock(data:any, sn:String, dockSn:String, workspaceId:String, ssLinePath:String, viewDroneInfo:any) { |
| | | // 获取workspaceId |
| | | wId = workspaceId |
| | | // 给无人机参数赋值 |
| | |
| | | measure_target_latitude = payloads.measure_target_latitude; |
| | | measure_target_altitude = payloads.measure_target_altitude; |
| | | |
| | | // if (laserEntity && laserEntity != null) { |
| | | // laserEntity.position = new globalCesium.CallbackProperty(function () { |
| | | // return position |
| | | // }, false) |
| | | // // laserEntity.orientation = new globalCesium.CallbackProperty(function () { |
| | | // // return orientation |
| | | // // }, false) |
| | | if (laserEntity && laserEntity != null) { |
| | | laserEntity.position = new globalCesium.CallbackProperty(function () { |
| | | return position |
| | | }, false) |
| | | |
| | | // laserEntity.show = true |
| | | |
| | | // window.cesiumViewer.scene.requestRender() |
| | | // } else { |
| | | laserEntity.show = true |
| | | window.cesiumViewer.scene.requestRender() |
| | | } else { |
| | | removeById('laser_coordinate') |
| | | laserEntity = window.cesiumViewer.entities.add({ |
| | | position: globalCesium.Cartesian3.fromDegrees(payloads.measure_target_longitude, payloads.measure_target_latitude, payloads.measure_target_altitude), |
| | | position: new globalCesium.CallbackProperty(() => { |
| | | return globalCesium.Cartesian3.fromDegrees( |
| | | payloads.measure_target_longitude, |
| | | payloads.measure_target_latitude, |
| | | payloads.measure_target_altitude |
| | | ) |
| | | }, false), |
| | | id: 'laser_coordinate', |
| | | billboard: { |
| | | image: imgLaser, |
| | |
| | | outlineWidth: 0, |
| | | } |
| | | }) |
| | | // } |
| | | } |
| | | // 增加激光扫射信息 |
| | | laserEntity.label = new globalCesium.LabelGraphics({ |
| | | text: `H:${Math.ceil(payloads.measure_target_altitude)}m-L:${Math.round(Math.ceil(payloads.measure_target_distance),)}m`, |
| | |
| | | console.log('起点',startPosition) |
| | | console.log('终点',position) |
| | | if (startPosition && position) { |
| | | removeById('route_two_line') |
| | | if (twoLineEntity && twoLineEntity != null) { |
| | | // 如果线实体已存在,只更新位置 |
| | | twoLineEntity.polyline.positions = new globalCesium.CallbackProperty(() => { |
| | | return [ |
| | | globalCesium.Cartesian3.fromDegrees(me_longitude, me_latitude, 0), |
| | | globalCesium.Cartesian3.fromDegrees( |
| | | payloads.measure_target_longitude, |
| | | payloads.measure_target_latitude, |
| | | payloads.measure_target_altitude |
| | | ) |
| | | ] |
| | | }, false) |
| | | } else { |
| | | // 如果线实体不存在,创建新的线实体 |
| | | twoLineEntity = window.cesiumViewer.entities.add({ |
| | | id: 'route_two_line', |
| | | polyline: { |
| | | positions: new globalCesium.CallbackProperty(() => [startPosition, position], false), |
| | | width: 3, |
| | | material: globalCesium.Color.RED, |
| | | zIndex: -1, |
| | | positions: new globalCesium.CallbackProperty(() => { |
| | | return [ |
| | | globalCesium.Cartesian3.fromDegrees(me_longitude, me_latitude, 0), |
| | | globalCesium.Cartesian3.fromDegrees( |
| | | payloads.measure_target_longitude, |
| | | payloads.measure_target_latitude, |
| | | payloads.measure_target_altitude |
| | | ) |
| | | ] |
| | | }, false), |
| | | width: 2, |
| | | material: globalCesium.Color.fromCssColorString('red'), |
| | | clampToGround: false, |
| | | } |
| | | }, |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | function getPhoneLocation(workspaceId:String) { |
| | | if (window.cesiumViewer == null) return |
| | | if (navigator.geolocation) { |
| | | navigator.geolocation.watchPosition((position) => { |
| | | console.log(me_longitude,position.coords.longitude) |
| | | console.log(me_latitude,position.coords.latitude) |
| | | 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; |
| | | // 创建一个箭头实体 |
| | | removeById('me_dw') |
| | | // 如果实体不存在,先创建实体 |
| | | if (!myAppEntity) { |
| | | myAppEntity = window.cesiumViewer.entities.add({ |
| | | id: 'me_dw', |
| | | position: globalCesium.Cartesian3.fromDegrees(me_longitude, me_latitude, me_altitude), |
| | | position: new globalCesium.CallbackProperty(() => { |
| | | return globalCesium.Cartesian3.fromDegrees(me_longitude, me_latitude, me_altitude) |
| | | }, false), |
| | | billboard: { |
| | | image: meMapSrc, // 箭头图片路径 |
| | | image: meMapSrc, |
| | | width: 30, |
| | | height: 30, |
| | | scale: 1.0, |
| | | outlineWidth: 0, |
| | | } |
| | | }); |
| | | } else { |
| | | myAppEntity.position = new globalCesium.CallbackProperty(() => { |
| | | return globalCesium.Cartesian3.fromDegrees(me_longitude, me_latitude, me_altitude) |
| | | }, false); |
| | | } |
| | | 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; |
| | | |
| | | // 查看两条线直接距离和高度 |
| | | getTwoHeightWidth(workspaceId) |
| | | }, (error) => { |