|
8 | 8 | */ |
9 | 9 |
|
10 | 10 | import DrawObject from "../../../service/PlotBase/Draw/DrawObject"; |
11 | | -import { PrimitiveFactory } from "../Primitive/PrimitiveFactory"; |
| 11 | +import {PrimitiveFactory} from "../Primitive/PrimitiveFactory"; |
12 | 12 | import {CesiumUtil} from "../Utils/CesiumUtil"; |
13 | 13 |
|
14 | 14 | export default class DrawPoint extends DrawObject { |
15 | | - constructor(viewer, symbol, plotLayer) { |
16 | | - super(); |
17 | | - this._viewer = viewer; |
18 | | - this._symbol = symbol; |
19 | | - this.m_coords = []; |
20 | | - this._primitive = null; |
21 | | - this._plotLayer = plotLayer; |
22 | | - } |
| 15 | + constructor(viewer, symbol, plotLayer) { |
| 16 | + super(); |
| 17 | + this._viewer = viewer; |
| 18 | + this._symbol = symbol; |
| 19 | + this.m_coords = []; |
| 20 | + this._primitive = null; |
| 21 | + this._plotLayer = plotLayer; |
| 22 | + } |
23 | 23 |
|
24 | | - addHooks() { |
25 | | - const viewer = this._viewer; |
26 | | - const symbol = this._symbol; |
27 | | - const handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas); |
28 | | - let that = this; |
29 | | - handler.setInputAction((event) => { |
30 | | - const worldPos = viewer.scene.globe.pick( |
31 | | - viewer.camera.getPickRay(event.position), |
32 | | - viewer.scene |
33 | | - ); |
| 24 | + addHooks() { |
| 25 | + const viewer = this._viewer; |
| 26 | + const symbol = this._symbol; |
| 27 | + const handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas); |
| 28 | + let that = this; |
| 29 | + handler.setInputAction((event) => { |
| 30 | + const worldPos = viewer.scene.globe.pick( |
| 31 | + viewer.camera.getPickRay(event.position), |
| 32 | + viewer.scene |
| 33 | + ); |
34 | 34 |
|
35 | | - if (!worldPos) return; |
| 35 | + if (!worldPos) return; |
36 | 36 |
|
37 | | - symbol.getElement().then(function (res) { |
38 | | - const {classificationType} = that._symbol; |
39 | | - res.classificationType = classificationType; |
40 | | - that._primitive = PrimitiveFactory.createInstance(symbol.type, { |
41 | | - positions: that.m_coords, |
42 | | - element: res |
43 | | - }); |
| 37 | + symbol.getElement().then(function (res) { |
| 38 | + const {classificationType} = that._symbol; |
| 39 | + res.classificationType = classificationType; |
| 40 | + const {style} = that._symbol; |
| 41 | + if(style){ |
| 42 | + res.initNodeStyles(style); |
| 43 | + } |
44 | 44 |
|
45 | | - const lnglat = CesiumUtil.cartesian3ToDegrees( |
46 | | - viewer.scene.globe.ellipsoid, |
47 | | - worldPos |
48 | | - ); |
49 | | - that.m_coords.push(lnglat); |
50 | | - that._plotLayer._primitiveCollection.add(that._primitive); |
| 45 | + that._primitive = PrimitiveFactory.createInstance(symbol.type, { |
| 46 | + positions: that.m_coords, |
| 47 | + element: res |
| 48 | + }); |
51 | 49 |
|
52 | | - that._primitive.positions = that.m_coords; |
53 | | - that.disable(); |
54 | | - that.fireFinishEvent({ plotObj3D: that._primitive }); |
55 | | - }); |
56 | | - }, Cesium.ScreenSpaceEventType.LEFT_CLICK); |
| 50 | + const lnglat = CesiumUtil.cartesian3ToDegrees( |
| 51 | + viewer.scene.globe.ellipsoid, |
| 52 | + worldPos |
| 53 | + ); |
| 54 | + that.m_coords.push(lnglat); |
| 55 | + that._plotLayer._primitiveCollection.add(that._primitive); |
57 | 56 |
|
58 | | - this._handler = handler; |
59 | | - } |
| 57 | + that._primitive.positions = that.m_coords; |
| 58 | + that.disable(); |
| 59 | + that.fireFinishEvent({plotObj3D: that._primitive}); |
| 60 | + }); |
| 61 | + }, Cesium.ScreenSpaceEventType.LEFT_CLICK); |
60 | 62 |
|
61 | | - removeHooks() { |
62 | | - const handler = this._handler; |
63 | | - // handler.removeInputAction(); |
64 | | - handler.destroy(); |
65 | | - this._handler = null; |
66 | | - } |
| 63 | + this._handler = handler; |
| 64 | + } |
| 65 | + |
| 66 | + removeHooks() { |
| 67 | + const handler = this._handler; |
| 68 | + // handler.removeInputAction(); |
| 69 | + handler.destroy(); |
| 70 | + this._handler = null; |
| 71 | + } |
67 | 72 | } |
0 commit comments