You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DrawPoint.js 1.1KB

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