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.

DrawPoint.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * @Author: Caven
  3. * @Date: 2020-01-31 16:25:29
  4. */
  5. import { Cesium } from '@dc-modules/namespace'
  6. import { Transform } from '@dc-modules/transform'
  7. import { Point } from '@dc-modules/overlay'
  8. import Draw from './Draw'
  9. const DEF_STYLE = {
  10. pixelSize: 10,
  11. outlineColor: Cesium.Color.BLUE,
  12. outlineWidth: 5
  13. }
  14. class DrawPoint extends Draw {
  15. constructor(style) {
  16. super()
  17. this._position = Cesium.Cartesian3.ZERO
  18. this._style = {
  19. ...DEF_STYLE,
  20. ...style
  21. }
  22. }
  23. _mountEntity() {
  24. this._delegate = new Cesium.Entity({
  25. position: new Cesium.CallbackProperty(() => {
  26. return this._position
  27. }, false),
  28. point: {
  29. ...this._style
  30. }
  31. })
  32. this._layer.add(this._delegate)
  33. }
  34. _onClick(e) {
  35. this._position = this._clampToGround ? e.surfacePosition : e.position
  36. this.unbindEvent()
  37. let point = new Point(Transform.transformCartesianToWGS84(this._position))
  38. point.setStyle(this._style)
  39. this._plotEvent.raiseEvent(point)
  40. }
  41. _onMouseMove(e) {
  42. this._tooltip.showAt(e.windowPosition, '单击选择点位')
  43. this._position = this._clampToGround ? e.surfacePosition : e.position
  44. }
  45. }
  46. export default DrawPoint