您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

DrawPoint.js 1.5KB

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