guanqb
2024-01-02 432456dea4e9f370f76a42f7b341596012c3c38f
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
74
75
76
77
78
79
80
/*
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2023-03-24 17:24:45
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2023-03-29 20:29:27
 * @FilePath: \srs-police-affairs\src\utils\plot\draw\DrawBillboard.js
 * @Description: 
 * 
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved. 
 */
/**
 * @Author: Caven
 * @Date: 2020-08-29 20:29:59
 */
import { PlotEventType } from '@/utils/event/index.js'
 
import Draw from './Draw'
 
const IMG_CIRCLE_RED = '/images/circle_red.png'
 
class DrawPoint extends Draw {
    constructor(style) {
        super()
        this._position = global.DC.Namespace.Cesium.Cartesian3.UNIT_Z
        this._style = {
            image: style.billboardImage ?? IMG_CIRCLE_RED,
            ...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),
            billboard: {
                ...this._style,
            }
        })
        this._layer.entities.add(this._delegate)
    }
 
    /**
     *
     * @private
     */
    _stopdHook () {
        let billboard = new global.DC.Billboard(
            global.DC.Transform.transformCartesianToWGS84(this._position),
            this._style.image
        ).setStyle(this._style)
        this._options.onDrawStop && this._options.onDrawStop(billboard)
    }
 
    /**
     *
     * @param position
     * @private
     */
    _onDrawAnchor (position) {
        this._position = position
        this.curDrawTool.fire(PlotEventType.DRAW_STOP)
    }
 
    /**
     *
     * @param position
     * @private
     */
    _onAnchorMoving (position) {
        this._position = position
    }
}
 
export default DrawPoint