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.3KB

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