Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

DrawBillboard.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * @Author: Caven
  3. * @Date: 2020-08-29 20:29:59
  4. */
  5. import { Cesium } from '@dc-modules/namespace'
  6. import { PlotEventType } from '@dc-modules/event'
  7. import { Transform } from '@dc-modules/transform'
  8. import { Billboard } from '@dc-modules/overlay'
  9. import Draw from './Draw'
  10. const IMG_CIRCLE_RED = require('@dc-modules/images/circle_red.png')
  11. class DrawPoint extends Draw {
  12. constructor(style) {
  13. super()
  14. this._position = Cesium.Cartesian3.ZERO
  15. this._style = {
  16. image: IMG_CIRCLE_RED,
  17. ...style
  18. }
  19. }
  20. /**
  21. *
  22. * @private
  23. */
  24. _mountedHook() {
  25. this.drawTool.tooltipMess = '单击选择点位'
  26. this._delegate = new Cesium.Entity({
  27. position: new Cesium.CallbackProperty(() => {
  28. return this._position
  29. }, false),
  30. billboard: {
  31. ...this._style
  32. }
  33. })
  34. this._layer.entities.add(this._delegate)
  35. }
  36. /**
  37. *
  38. * @private
  39. */
  40. _stopdHook() {
  41. let billboard = new Billboard(
  42. Transform.transformCartesianToWGS84(this._position),
  43. this._style.image
  44. ).setStyle(this._style)
  45. this._options.onDrawStop && this._options.onDrawStop(billboard)
  46. }
  47. /**
  48. *
  49. * @param position
  50. * @private
  51. */
  52. _onDrawAnchor(position) {
  53. this._position = position
  54. this.drawTool.fire(PlotEventType.DRAW_STOP)
  55. }
  56. /**
  57. *
  58. * @param position
  59. * @private
  60. */
  61. _onAnchorMoving(position) {
  62. this._position = position
  63. }
  64. }
  65. export default DrawPoint