/**
|
* @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
|