Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Draw.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * @Author: Caven
  3. * @Date: 2020-01-31 19:45:32
  4. */
  5. const { MouseEventType } = DC
  6. const { Cesium } = DC.Namespace
  7. class Draw {
  8. constructor() {
  9. this._viewer = undefined
  10. this._delegate = undefined
  11. this._floatingAnchor = undefined
  12. this._clampToGround = true
  13. this._tooltip = undefined
  14. this._layer = undefined
  15. this._plotEvent = undefined
  16. this._options = {}
  17. }
  18. _mountEntity() {}
  19. _onClick(e) {}
  20. _onMouseMove(e) {}
  21. _onRightClick(e) {}
  22. bindEvent() {
  23. this._viewer.on(MouseEventType.CLICK, this._onClick, this)
  24. this._viewer.on(MouseEventType.MOUSE_MOVE, this._onMouseMove, this)
  25. this._viewer.on(MouseEventType.RIGHT_CLICK, this._onRightClick, this)
  26. }
  27. unbindEvent() {
  28. this._viewer.off(MouseEventType.CLICK, this._onClick, this)
  29. this._viewer.off(MouseEventType.MOUSE_MOVE, this._onMouseMove, this)
  30. this._viewer.off(MouseEventType.RIGHT_CLICK, this._onRightClick, this)
  31. }
  32. createAnchor(position, isCenter = false) {
  33. return this._layer.add({
  34. position: position,
  35. billboard: {
  36. image: isCenter ? this._options.icon_center : this._options.icon_anchor,
  37. width: this._options.icon_size[0],
  38. height: this._options.icon_size[1],
  39. eyeOffset: new Cesium.Cartesian3(0, 0, -500),
  40. heightReference:
  41. this._viewer.scene.mode === Cesium.SceneMode.SCENE3D &&
  42. this._clampToGround
  43. ? Cesium.HeightReference.CLAMP_TO_GROUND
  44. : Cesium.HeightReference.NONE
  45. }
  46. })
  47. }
  48. start(plot) {
  49. this._viewer = plot.viewer
  50. this._tooltip = plot.viewer.tooltip
  51. this._layer = plot.overlayLayer
  52. this._plotEvent = plot.plotEvent
  53. this._options = plot.options
  54. this._clampToGround = plot.options.clampToGround ?? true
  55. this._mountEntity()
  56. this.bindEvent()
  57. }
  58. }
  59. export default Draw