Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

EditTailedAttackArrow.js 2.0KB

před 4 roky
před 4 roky
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * @Author: Caven
  3. * @Date: 2020-08-30 23:46:07
  4. */
  5. import { Cesium } from '@dc-modules/namespace'
  6. import { Transform } from '@dc-modules/transform'
  7. import Edit from './Edit'
  8. import TailedAttackArrowGraphics from '../graphics/TailedAttackArrowGraphics'
  9. class EditTailedAttackArrow extends Edit {
  10. constructor(overlay) {
  11. super()
  12. this._overlay = overlay
  13. this._positions = []
  14. this._graphics = new TailedAttackArrowGraphics()
  15. }
  16. _mountEntity() {
  17. this._delegate = new Cesium.Entity()
  18. this._delegate.merge(this._overlay.delegate)
  19. this._overlay.show = false
  20. this._delegate.polygon.hierarchy = new Cesium.CallbackProperty(() => {
  21. if (this._positions.length > 2) {
  22. this._graphics.positions = this._positions
  23. return this._graphics.hierarchy
  24. } else {
  25. return null
  26. }
  27. }, false)
  28. this._layer.add(this._delegate)
  29. }
  30. _mountAnchor() {
  31. this._positions = [].concat(
  32. Transform.transformWGS84ArrayToCartesianArray(this._overlay.positions)
  33. )
  34. this._positions.forEach((item, index) => {
  35. this.createAnchor(item, index)
  36. })
  37. }
  38. _onClick(e) {
  39. if (this._isMoving) {
  40. this._isMoving = false
  41. if (this._pickedAnchor && this._pickedAnchor.position) {
  42. let position = this._clampToGround ? e.surfacePosition : e.position
  43. if (!position) {
  44. return false
  45. }
  46. let properties = this._pickedAnchor.properties.getValue(
  47. Cesium.JulianDate.now()
  48. )
  49. this._pickedAnchor.position.setValue(position)
  50. this._positions[properties.index] = position
  51. }
  52. } else {
  53. this._isMoving = true
  54. if (!e.target || !e.target.id) {
  55. return false
  56. }
  57. this._pickedAnchor = e.target.id
  58. }
  59. }
  60. _onRightClick(e) {
  61. this.unbindEvent()
  62. this._overlay.positions = Transform.transformCartesianArrayToWGS84Array(
  63. this._positions
  64. )
  65. this._overlay.show = true
  66. this._plotEvent.raiseEvent(this._overlay)
  67. }
  68. }
  69. export default EditTailedAttackArrow