| | |
| | | outlineWidth: number, |
| | | [key: string]: any |
| | | } |
| | | interface polyline { |
| | | width?: number |
| | | material?: Cesium.Color |
| | | [key: string]: any |
| | | } |
| | | interface pointOption { |
| | | longitude: number |
| | | latitude: number |
| | | point?: pointSetting |
| | | billboard?: billboardSetting |
| | | polyline?: polyline |
| | | 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) |
| | | viewer?.entities.add({ |
| | | position: Cesium.Cartesian3.fromDegrees(pointOption.longitude, pointOption.latitude), |
| | | position, |
| | | billboard: pointOption.billboard, |
| | | point: pointOption.point, |
| | | label: pointOption.label, |
| | | id: pointOption.id, |
| | | }) |
| | | } |
| | | |
| | | // 添加线段 |
| | | const addPolyline = (pointOption: pointOption) => { |
| | | viewer?.entities.add({ |
| | | polyline: pointOption.polyline, |
| | | id: pointOption.id, |
| | | }) |
| | | } |
| | |
| | | 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) |
| | | if (Cesium.defined(entity)) { |
| | | entity.position = position |
| | | entity.billboard.rotation = heading |
| | | } |
| | | } |
| | | // 飞行 flyto |
| | | const flyTo = (pointOption: pointOption, time: number = 4) => { |
| | | const flyTo = (pointOption: pointOption, time: number = 4, height:number = 3000) => { |
| | | if (!pointOption.longitude && !pointOption.latitude) return |
| | | const destination = Cesium.Cartesian3.fromDegrees(pointOption.longitude, pointOption.latitude, 3000) |
| | | const destination = Cesium.Cartesian3.fromDegrees(pointOption.longitude, pointOption.latitude, height) |
| | | const duration = time |
| | | viewer?.camera.flyTo({ |
| | | destination, |
| | |
| | | // 切换不同背景图层 |
| | | const patternMap = () => { |
| | | const imageryLayers = viewer?.scene.imageryLayers |
| | | console.log(imageryLayers, 'imageryLayers') |
| | | // 切换为标准图层 |
| | | if (store.state.common.mapSetting.mode === 0) { |
| | | const tdtImg_c = imageryLayers?._layers.find(v => v.imageryProvider._layer === 'tdtImg_c') |
| | |
| | | } else { |
| | | const tdtStand_c = imageryLayers?._layers.find(v => v.imageryProvider.credit.html === 'stand_tc') |
| | | const tdtStand_zj = imageryLayers?._layers.find(v => v.imageryProvider.credit.html === 'stand_zj') |
| | | console.log(tdtStand_c, tdtStand_zj, '===========================') |
| | | viewer?.imageryLayers.remove(tdtStand_c) |
| | | viewer?.imageryLayers.remove(tdtStand_zj) |
| | | } |
| | |
| | | zoonIn, |
| | | zoonOut, |
| | | roadPattern, |
| | | patternMap |
| | | patternMap, |
| | | getEntityById, |
| | | updateEntityPosition, |
| | | addPolyline |
| | | } |
| | | } |