Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

DrawPolygon.js 998B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * @Author : Caven Chen
  3. */
  4. import { Cesium } from '../../../namespace'
  5. import { PlotEventType } from '../../event'
  6. import Draw from './Draw'
  7. class DrawPolygon extends Draw {
  8. constructor(style) {
  9. super(style)
  10. }
  11. /**
  12. *
  13. * @private
  14. */
  15. _mountedHook() {
  16. this.drawTool.tooltipMess = '左击选择点位,右击结束'
  17. this._delegate = new Cesium.Entity({
  18. polygon: {
  19. ...this._style,
  20. hierarchy: new Cesium.CallbackProperty(() => {
  21. if (this._positions.length > 2) {
  22. return new Cesium.PolygonHierarchy(
  23. this._positions.map((item) => item.clone())
  24. )
  25. } else {
  26. return null
  27. }
  28. }, false),
  29. },
  30. })
  31. this._layer.entities.add(this._delegate)
  32. }
  33. /**
  34. *
  35. * @param position
  36. * @private
  37. */
  38. _onDrawAnchor(position) {
  39. this._positions.push(position)
  40. this.drawTool.fire(PlotEventType.CREATE_ANCHOR, { position })
  41. }
  42. }
  43. export default DrawPolygon