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ů.

PointPrimitive.js 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * @Author: Caven
  3. * @Date: 2021-06-03 20:51:25
  4. */
  5. import { Cesium } from '@dc-modules/namespace'
  6. import State from '@dc-modules/state/State'
  7. import Parse from '@dc-modules/parse/Parse'
  8. import { Util } from '@dc-modules/utils'
  9. import { Transform } from '@dc-modules/transform'
  10. import Overlay from '../Overlay'
  11. const DEF_STYLE = {
  12. pixelSize: 8,
  13. outlineColor: Cesium.Color.BLUE,
  14. outlineWidth: 2
  15. }
  16. class PointPrimitive extends Overlay {
  17. constructor(position) {
  18. super()
  19. this._position = Parse.parsePosition(position)
  20. this.type = Overlay.getOverlayType('point_primitive')
  21. this._delegate = {
  22. position: undefined
  23. }
  24. this._state = State.INITIALIZED
  25. }
  26. set position(position) {
  27. this._position = Parse.parsePosition(position)
  28. this._delegate.position = Transform.transformWGS84ToCartesian(
  29. this._position
  30. )
  31. return this
  32. }
  33. get position() {
  34. return this._position
  35. }
  36. _mountedHook() {
  37. /**
  38. * set the location
  39. */
  40. this.position = this._position
  41. /**
  42. * initialize the Overlay parameter
  43. */
  44. Util.merge(this._delegate, DEF_STYLE, this._style)
  45. }
  46. /**
  47. * Set style
  48. * @param style
  49. * @returns {PointPrimitive}
  50. */
  51. setStyle(style) {
  52. if (!style || Object.keys(style).length === 0) {
  53. return this
  54. }
  55. delete style['position']
  56. this._style = style
  57. Util.merge(this._delegate, DEF_STYLE, this._style)
  58. return this
  59. }
  60. }
  61. Overlay.registerType('point_primitive')
  62. export default PointPrimitive