tool3DMeasureHeight.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. define(function () {
  2. /**
  3. * 状态值
  4. * @type {Boolean}
  5. * @default false
  6. * @private
  7. */
  8. var status = {
  9. initialized: false, //是否初始化
  10. };
  11. /**
  12. * 模块数据 用于数据存储和外部调用
  13. * @type {Object}
  14. * 数据存放
  15. */
  16. var modValue = {
  17. title: "测高",
  18. };
  19. /**
  20. * 3D 通视初始化
  21. */
  22. function init() {
  23. if (!status.initialized) {
  24. subscribe();
  25. status.initialized = true;
  26. }
  27. ONEMAP.C.publisher.publish({
  28. modName: 'tool3DMeasureHeight'
  29. }, 'tools:active');
  30. };
  31. /**
  32. * 注册监听事件
  33. */
  34. function subscribe() {
  35. ONEMAP.C.publisher.subscribe(remove, 'tools:active');
  36. ONEMAP.C.publisher.subscribe(clear, 'cleanMap');
  37. ONEMAP.C.publisher.subscribe(removeEvent, 'change23D');
  38. };
  39. // 23D转换
  40. function removeEvent() {
  41. map3DViewer.measureHeight({
  42. action: "remove"
  43. })
  44. if ($(".tools-measuringHeight").hasClass('cur')) {
  45. $(".tools-measuringHeight").removeClass('cur');
  46. }
  47. }
  48. /**
  49. * 3D通视 加载/移除 注册事件
  50. */
  51. function remove(options) {
  52. if (options.modName != 'tool3DMeasureHeight') {
  53. if (options.modName == 'cleanMap') {
  54. clear();
  55. }
  56. removeAndClear();
  57. $(".tools-measuringHeight").removeClass('cur');
  58. } else {
  59. if ($(".tools-measuringHeight").hasClass('cur')) {
  60. $(".tools-measuringHeight").removeClass('cur');
  61. removeAndClear();
  62. } else {
  63. $(".tools-measuringHeight").addClass('cur');
  64. map3DViewer.measureHeight({
  65. action: "add",
  66. afterMeasureJudgeContinue: true
  67. })
  68. }
  69. }
  70. }
  71. /**
  72. * 移除 3D测高
  73. */
  74. function removeAndClear() {
  75. map3DViewer.measureHeight({
  76. action: "stop"
  77. })
  78. };
  79. /**
  80. * 清除绘制 3D测高
  81. */
  82. function clear() {
  83. map3DViewer.measureHeight({
  84. action: "clear"
  85. })
  86. }
  87. return ONEMAP.M.tool3DMeasureHeight = {
  88. init: init
  89. }
  90. })