| | |
| | | [key: string]: any |
| | | } |
| | | interface pointOption { |
| | | longitude: number |
| | | latitude: number |
| | | longitude?: number |
| | | latitude?: number |
| | | point?: pointSetting |
| | | billboard?: billboardSetting |
| | | polyline?: polyline |
| | |
| | | } |
| | | } |
| | | |
| | | function removeAllDataSource () { |
| | | function removeAllDataSource() { |
| | | viewer.dataSources.removeAll() |
| | | } |
| | | |
| | |
| | | ellipse: { |
| | | semiMinorAxis: 7000.0, |
| | | semiMajorAxis: 7000.0, |
| | | material: Cesium.Color.CORNFLOWERBLUE.withAlpha(0.3), |
| | | outline: true, |
| | | material: Cesium.Color.CORNFLOWERBLUE.withAlpha(0.3) |
| | | } |
| | | }) |
| | | console.log(viewer?.entities) |
| | | } |
| | | |
| | | // 添加点击事件 |
| | | const addClickEvent = (sid: string, cb: Function) => { |
| | | const handler = new Cesium.ScreenSpaceEventHandler(viewer?.scene.canvas) |
| | | handler.setInputAction(function (click: { position: Cesium.Cartesian2 }) { |
| | | const pick = viewer?.scene.pick(click.position) |
| | | if (pick && pick.id._id === sid) { |
| | | cb(click, pick, viewer) |
| | | } |
| | | }, Cesium.ScreenSpaceEventType.LEFT_CLICK) |
| | | } |
| | | |
| | | // 添加线段 |
| | |
| | | } |
| | | |
| | | // 加载json文件 |
| | | const loadGeoJson = (url:string) => { |
| | | const loadGeoJson = (url: string) => { |
| | | const option = { |
| | | stroke: Cesium.Color.HOTPINK, |
| | | fill: Cesium.Color.PINK, |
| | |
| | | |
| | | promise.then(dataSource => { |
| | | console.log(dataSource) |
| | | viewer.dataSources.add(dataSource) |
| | | viewer?.dataSources.add(dataSource) |
| | | }) |
| | | } |
| | | |
| | |
| | | addPolyline, |
| | | addEllipse, |
| | | loadGeoJson, |
| | | removeAllDataSource |
| | | removeAllDataSource, |
| | | addClickEvent |
| | | } |
| | | } |