Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

DrawBillboard.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * @Author: Caven
  3. * @Date: 2020-08-29 20:29:59
  4. */
  5. import Draw from './Draw'
  6. const { Transform } = DC
  7. const { Cesium } = DC.Namespace
  8. const DEF_STYLE = {}
  9. const IMG_CIRCLE_RED = require('@dc-modules/images/circle_red.png')
  10. class DrawPoint extends Draw {
  11. constructor(style) {
  12. super()
  13. this._position = Cesium.Cartesian3.ZERO
  14. this._style = {
  15. image: IMG_CIRCLE_RED,
  16. ...DEF_STYLE,
  17. ...style
  18. }
  19. }
  20. _mountEntity() {
  21. this._delegate = new Cesium.Entity({
  22. position: new Cesium.CallbackProperty(() => {
  23. return this._position
  24. }, false),
  25. billboard: {
  26. ...this._style
  27. }
  28. })
  29. this._layer.add(this._delegate)
  30. }
  31. _onClick(e) {
  32. this._position = this._clampToGround ? e.surfacePosition : e.position
  33. this.unbindEvent()
  34. let billboard = new DC.Billboard(
  35. Transform.transformCartesianToWGS84(this._position),
  36. this._style.image
  37. )
  38. billboard.setStyle(this._style)
  39. this._plotEvent.raiseEvent(billboard)
  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