| | |
| | | billboard?: billboardSetting |
| | | label?: labelSetting |
| | | id?: string |
| | | heading?: number |
| | | pitch?: number |
| | | roll?: number |
| | | } |
| | | // 定义全局的viewer变量防止重复生成 |
| | | // eslint-disable-next-line no-var |
| | |
| | | // 添加标记点 |
| | | const addPoint = (pointOption: pointOption) => { |
| | | if (!pointOption.longitude && !pointOption.latitude) return |
| | | const position = Cesium.Cartesian3.fromDegrees(pointOption.longitude, pointOption.latitude) |
| | | const orientation = Cesium.Transforms.headingPitchRollQuaternion(position, new Cesium.HeadingPitchRoll(pointOption.heading, pointOption.pitch, pointOption.roll)) |
| | | viewer?.entities.add({ |
| | | position: Cesium.Cartesian3.fromDegrees(pointOption.longitude, pointOption.latitude), |
| | | billboard: pointOption.billboard, |
| | | point: pointOption.point, |
| | | label: pointOption.label, |
| | | id: pointOption.id, |
| | | orientation |
| | | }) |
| | | } |
| | | |
| | |
| | | viewer?.entities.remove(pointEntity) |
| | | } |
| | | } |
| | | |
| | | // 通过点ID获取实体 |
| | | function getEntityById (id:string) { |
| | | const pointEntity = viewer?.entities.getById(id) |
| | | return pointEntity |
| | | } |
| | | // 更新实体位置 |
| | | function updateEntityPosition (longitude:number, latitude:number, id:string, params?:any) { |
| | | const entity = getEntityById(id) as Cesium.Entity |
| | | const position = Cesium.Cartesian3.fromDegrees(longitude, latitude) |
| | | const heading = Cesium.Math.toRadians(params.heading) |
| | | const pitch = Cesium.Math.toRadians(params.pitch) |
| | | const roll = Cesium.Math.toRadians(params.roll) |
| | | const orientation = Cesium.Transforms.headingPitchRollQuaternion(position, new Cesium.HeadingPitchRoll(heading, pitch, roll)) |
| | | if (Cesium.defined(entity)) { |
| | | entity.position = position |
| | | entity.orientation = orientation |
| | | } |
| | | } |
| | | // 飞行 flyto |
| | | const flyTo = (pointOption: pointOption, time: number = 4) => { |
| | | if (!pointOption.longitude && !pointOption.latitude) return |
| | |
| | | zoonIn, |
| | | zoonOut, |
| | | roadPattern, |
| | | patternMap |
| | | patternMap, |
| | | getEntityById, |
| | | updateEntityPosition |
| | | } |
| | | } |