jxdnsong
2023-04-05 be147d2a99d60a30b20fade742e85b45f06172ae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
 * @Author: Caven
 * @Date: 2020-01-31 16:25:29
 */
 
import { PlotEventType } from '@/utils/event/index.js'
import Draw from './Draw'
 
const DEF_STYLE = {
    pixelSize: 10,
    outlineColor: global.DC.Namespace.Cesium.Color.BLUE,
    outlineWidth: 5
}
 
class DrawPoint extends Draw {
    constructor(style) {
        super()
        this._position = global.DC.Namespace.Cesium.Cartesian3.ZERO
        this._style = {
            ...DEF_STYLE,
            ...style
        }
    }
 
    /**
     *
     * @private
     */
    _mountedHook () {
        this.curDrawTool.tooltipMess = '单击选择点位'
        this._delegate = new global.DC.Namespace.Cesium.Entity({
            position: new global.DC.Namespace.Cesium.CallbackProperty(() => {
                return this._position
            }, false),
            point: {
                ...this._style
            }
        })
        this._layer.entities.add(this._delegate)
    }
 
    /**
     *
     * @private
     */
    _stopdHook () {
        let point = new global.DC.Point(
            global.DC.Transform.transformCartesianToWGS84(this._position)
        ).setStyle(this._style)
        this._options.onDrawStop && this._options.onDrawStop(point)
    }
 
    /**
     *
     * @param position
     * @private
     */
    _onDrawAnchor (position) {
        this._position = position
        this.curDrawTool.fire(PlotEventType.DRAW_STOP, position)
    }
 
    /**
     *
     * @param position
     * @private
     */
    _onAnchorMoving (position) {
        this._position = position
    }
}
 
export default DrawPoint