選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

PointPrimitive.js 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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._delegate = {
  21. position: undefined
  22. }
  23. this._state = State.INITIALIZED
  24. }
  25. get type() {
  26. return Overlay.getOverlayType('point_primitive')
  27. }
  28. set position(position) {
  29. this._position = Parse.parsePosition(position)
  30. this._delegate.position = Transform.transformWGS84ToCartesian(
  31. this._position
  32. )
  33. return this
  34. }
  35. get position() {
  36. return this._position
  37. }
  38. _mountedHook() {
  39. /**
  40. * set the location
  41. */
  42. this.position = this._position
  43. /**
  44. * initialize the Overlay parameter
  45. */
  46. Util.merge(this._delegate, DEF_STYLE, this._style)
  47. }
  48. /**
  49. * Set style
  50. * @param style
  51. * @returns {PointPrimitive}
  52. */
  53. setStyle(style) {
  54. if (!style || Object.keys(style).length === 0) {
  55. return this
  56. }
  57. delete style['position']
  58. this._style = style
  59. Util.merge(this._delegate, DEF_STYLE, this._style)
  60. return this
  61. }
  62. }
  63. Overlay.registerType('point_primitive')
  64. export default PointPrimitive