/*
|
* @Author: shuishen 1109946754@qq.com
|
* @Date: 2023-03-24 16:00:08
|
* @LastEditors: shuishen 1109946754@qq.com
|
* @LastEditTime: 2023-03-24 16:26:17
|
* @FilePath: \forest-fire\src\utils\plot\draw\DrawPolyline.js
|
* @Description:
|
*
|
* Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
|
*/
|
/**
|
* @Author: Caven
|
* @Date: 2020-08-29 20:54:37
|
*/
|
|
import Draw from './Draw'
|
import { PlotEventType } from '@/utils/event/index.js'
|
|
const DEF_STYLE = {
|
width: 3,
|
material: global.DC.Namespace.Cesium.Color.YELLOW.withAlpha(0.6)
|
}
|
|
class DrawPolyline extends Draw {
|
constructor(style) {
|
super()
|
this._style = {
|
...DEF_STYLE,
|
...style
|
}
|
}
|
|
/**
|
*
|
* @private
|
*/
|
_mountedHook () {
|
this.curDrawTool.tooltipMess = '左击选择点位,右击结束'
|
this._delegate = new global.DC.Namespace.Cesium.Entity({
|
polyline: {
|
...this._style,
|
positions: new global.DC.Namespace.Cesium.CallbackProperty(() => {
|
return this._positions
|
}, false)
|
}
|
})
|
this._layer.entities.add(this._delegate)
|
}
|
|
/**
|
*
|
* @private
|
*/
|
_stopdHook () {
|
let polyline = new global.DC.Polyline(
|
global.DC.Transform.transformCartesianArrayToWGS84Array(this._positions)
|
).setStyle(this._style)
|
this._options.onDrawStop && this._options.onDrawStop(polyline)
|
}
|
|
/**
|
*
|
* @param position
|
* @returns {boolean}
|
* @private
|
*/
|
_onDrawAnchor (position) {
|
this._positions.push(position)
|
this.curDrawTool.fire(PlotEventType.CREATE_ANCHOR, { position })
|
}
|
}
|
|
export default DrawPolyline
|