Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

DrawPoint.js 1.4KB

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