You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * @Author: Caven
  3. * @Date: 2021-06-03 22:28:49
  4. */
  5. import State from '@dc-modules/state/State'
  6. import Parse from '@dc-modules/parse/Parse'
  7. import { Util } from '@dc-modules/utils'
  8. import { Transform } from '@dc-modules/transform'
  9. import Overlay from '../Overlay'
  10. class LabelPrimitive extends Overlay {
  11. constructor(position, text) {
  12. super()
  13. this._position = Parse.parsePosition(position)
  14. this._text = text
  15. this._delegate = {
  16. position: undefined,
  17. text: undefined
  18. }
  19. this.type = Overlay.getOverlayType('label_primitive')
  20. this._state = State.INITIALIZED
  21. }
  22. set position(position) {
  23. this._position = Parse.parsePosition(position)
  24. this._delegate.position = Transform.transformWGS84ToCartesian(
  25. this._position
  26. )
  27. return this
  28. }
  29. get position() {
  30. return this._position
  31. }
  32. set text(text) {
  33. this._text = text
  34. this._delegate.text = this._text
  35. return this
  36. }
  37. get text() {
  38. return this._text
  39. }
  40. _mountedHook() {
  41. /**
  42. * set the location
  43. */
  44. this.position = this._position
  45. /**
  46. * initialize the Overlay parameter
  47. */
  48. this.text = this._text
  49. }
  50. /**
  51. *
  52. * @param {*} text
  53. * @param {*} textStyle
  54. */
  55. setLabel(text, textStyle) {
  56. return this
  57. }
  58. /**
  59. * Sets Style
  60. * @param style
  61. * @returns {LabelPrimitive}
  62. */
  63. setStyle(style) {
  64. if (!style || Object.keys(style).length === 0) {
  65. return this
  66. }
  67. delete style['position'] && delete style['text']
  68. this._style = style
  69. Util.merge(this._delegate, this._style)
  70. return this
  71. }
  72. }
  73. Overlay.registerType('label_primitive')
  74. export default LabelPrimitive