|
| 1 | +import { CesiumZondy } from "../core/Base"; |
| 2 | + |
| 3 | +import BaseLayer from "./BaseLayer"; |
| 4 | + |
| 5 | +/** |
| 6 | + * @author 三维基础平台研发中心·邱文坤 |
| 7 | + * @class LayerManager.EntityController |
| 8 | + * @category LayerManager |
| 9 | + * @classdesc 实体绘制控制器类 |
| 10 | + * @description 该类实现了实体数据的绘制与删除功能 |
| 11 | + * @param option.viewer = viewer 视图 |
| 12 | + * @see |
| 13 | + */ |
| 14 | +export default class EntityController extends BaseLayer { |
| 15 | + constructor(option) { |
| 16 | + super(option); |
| 17 | + } |
| 18 | + |
| 19 | + /** |
| 20 | + * 添加点 |
| 21 | + * @param {Number} lat 经度 |
| 22 | + * @param {Number} lon 纬度 |
| 23 | + * @param {Number} height 高程 |
| 24 | + * @param {String} name 名称 |
| 25 | + * @param {Number} pixelSize 像素大小 |
| 26 | + * @param {Color} color (webGlobe.getColor(1,0,0,1))颜色 |
| 27 | + * @param {Color} outlineColor 外边线颜色 |
| 28 | + * @param {Number} outlineWidth 边线宽度 |
| 29 | + * @param {string} description 属性描述信息 |
| 30 | + * @example |
| 31 | + * let entityController = new EntityController({viewer}); |
| 32 | + * let color1 = new Cesium.Color(1, 0, 0, 1); |
| 33 | + * let color2 = new Cesium.Color(1, 1, 0, 1); |
| 34 | + * let point = entityController.appendPoint(115.2, 31, 200, '点', 100, color1, color2, 2); |
| 35 | + * // 跳转到点位置 |
| 36 | + * viewer.flyTo(point); |
| 37 | + * |
| 38 | + * @returns {entity} 返回点对象 移除通过removeEntity(entity) |
| 39 | + */ |
| 40 | + appendPoint( |
| 41 | + lat, |
| 42 | + lon, |
| 43 | + height, |
| 44 | + name, |
| 45 | + pixelSize, |
| 46 | + color, |
| 47 | + outlineColor, |
| 48 | + outlineWidth, |
| 49 | + description, |
| 50 | + ) { |
| 51 | + if (undefined === this.viewer) { |
| 52 | + return undefined; |
| 53 | + } |
| 54 | + let point = this.viewer.entities.add({ |
| 55 | + name: name, |
| 56 | + position: Cesium.Cartesian3.fromDegrees(lat, lon, height), |
| 57 | + point: { |
| 58 | + //点 |
| 59 | + pixelSize: pixelSize, |
| 60 | + color: color, |
| 61 | + outlineColor: outlineColor, |
| 62 | + outlineWidth: outlineWidth, |
| 63 | + }, |
| 64 | + description: description, |
| 65 | + }); |
| 66 | + return point; |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * 通用添加点 |
| 71 | + * @param {Number} lat 经度 |
| 72 | + * @param {Number} lon 纬度 |
| 73 | + * @param {Number} height 高程 |
| 74 | + * @param {String} name 名称 |
| 75 | + * @param {string} description 属性描述信息 |
| 76 | + * @param {object} options entity参数信息对象 |
| 77 | + */ |
| 78 | + appendPointComm(lat, lon, height, name, description, options) { |
| 79 | + let param = { |
| 80 | + name: name, |
| 81 | + position: Cesium.Cartesian3.fromDegrees(lat, lon, height), |
| 82 | + point: new Cesium.PointGraphics(), |
| 83 | + description: description, |
| 84 | + }; |
| 85 | + if (Cesium.defined(options)) { |
| 86 | + Object.extend(param, options); |
| 87 | + } |
| 88 | + var point = this.viewer.entities.add(param); |
| 89 | + return point; |
| 90 | + } |
| 91 | +} |
| 92 | + |
| 93 | +CesiumZondy.Layer.EntityController = EntityController; |
0 commit comments