Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

EditAttackArrow.js 1.9KB

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