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.

DrawPoint.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * @Author: Caven
  3. * @Date: 2020-01-31 16:25:29
  4. * @Last Modified by: Caven
  5. * @Last Modified time: 2020-05-11 23:09:24
  6. */
  7. import Draw from './Draw'
  8. const { OverlayType, Transform } = DC
  9. const { Cesium } = DC.NameSpace
  10. const DEF_STYLE = {
  11. pixelSize: 10,
  12. outlineColor: Cesium.Color.BLUE,
  13. outlineWidth: 5
  14. }
  15. class DrawPoint extends Draw {
  16. constructor(plotInfo, style) {
  17. super(plotInfo)
  18. this._position = Cesium.Cartesian3.ZERO
  19. this._style = {
  20. ...DEF_STYLE,
  21. ...style
  22. }
  23. }
  24. _mouseClickHandler(e) {
  25. this._position = e.target ? e.position : e.surfacePosition
  26. this._unbindEnvet()
  27. this._plotEvent.raiseEvent({
  28. type: OverlayType.POINT,
  29. points: [Transform.transformCartesianToWGS84(this._position)]
  30. })
  31. }
  32. _mouseMoveHandler(e) {
  33. this._position = e.target ? e.position : e.surfacePosition
  34. this._viewer.tooltip.showAt(e.windowPosition, '单击选择点位')
  35. }
  36. _prepareDelegate() {
  37. this._delegate.position = new Cesium.CallbackProperty(time => {
  38. return this._position
  39. })
  40. this._delegate.point = {
  41. ...this._style
  42. }
  43. this._layer.entities.add(this._delegate)
  44. }
  45. }
  46. export default DrawPoint