tool3DRadar.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. map3DViewer.radar({
  27. action: "add",
  28. callback: callback
  29. })
  30. }
  31. ONEMAP.C.publisher.publish({
  32. modName: 'tool3DRadar'
  33. }, 'tools:active');
  34. };
  35. /**
  36. * 注册监听事件
  37. */
  38. function subscribe() {
  39. ONEMAP.C.publisher.subscribe(remove, 'tools:active');
  40. ONEMAP.C.publisher.subscribe(clear, 'cleanMap');
  41. ONEMAP.C.publisher.subscribe(removeEvent, 'change23D');
  42. };
  43. // 23D转换
  44. function removeEvent() {
  45. map3DViewer.radar({
  46. action: "remove"
  47. })
  48. $('#toolRadarPanel').remove();
  49. if ($(".tools-radar").hasClass('cur')) {
  50. $(".tools-radar").removeClass('cur');
  51. }
  52. }
  53. /**
  54. * 雷达 加载/移除 注册事件
  55. */
  56. function remove(options) {
  57. if (options.modName != 'tool3DRadar') {
  58. if (options.modName == 'cleanMap') {
  59. clear();
  60. }
  61. removeAndClear();
  62. $(".tools-radar").removeClass('cur');
  63. } else {
  64. if ($(".tools-radar").hasClass('cur')) {
  65. $(".tools-radar").removeClass('cur');
  66. removeAndClear();
  67. } else {
  68. $(".tools-radar").addClass('cur');
  69. addPopup();
  70. }
  71. }
  72. }
  73. /**
  74. * 移除 雷达
  75. */
  76. function removeAndClear() {
  77. map3DViewer.radar({
  78. action: "stop"
  79. })
  80. $('#toolRadarPanel').remove();
  81. };
  82. /**
  83. * 清除绘制 雷达
  84. */
  85. function clear() {
  86. map3DViewer.radar({
  87. action: "remove"
  88. })
  89. }
  90. /**
  91. * 雷达分析后的回调
  92. */
  93. function callback() {
  94. // 退出
  95. ONEMAP.C.publisher.publish({
  96. modName: 'tool3DRadar'
  97. }, 'tools:active');
  98. }
  99. // 添加 弹窗
  100. function addPopup() {
  101. var html = '<div id="toolRadarPanel" class="viewHeightPopup class3d">' +
  102. ' <iframe frameborder="0" class="cover-iframe"></iframe>' +
  103. ' <div class="cover-content">' +
  104. ' <div class="">' +
  105. ' <div class="popup-lt"></div>' +
  106. ' <div class="popup-lb"></div>' +
  107. ' <div class="popup-rt"></div>' +
  108. ' <div class="popup-rb"></div>' +
  109. ' <div class="popup-ct">' +
  110. ' <button type="button" class="close"></button>' +
  111. ' <h3>' + modValue.title + '</h3>' +
  112. ' </div>' +
  113. ' <div class="popup-cb">' +
  114. ' <div class="panel">' +
  115. ' <span>视高:</span>' +
  116. ' <input class="input" value="3" id="viewHeight" /><span>米</span></br>' +
  117. ' <span>半径:</span>' +
  118. ' <input class="input" value="3" id="radius" /><span>米</span>' +
  119. ' <button class="btn btn2 sure">确定</button>' +
  120. ' <button class="btn btn2 cancel">取消</button>' +
  121. ' </div>' +
  122. ' </div>' +
  123. ' </div>' +
  124. ' </div>' +
  125. '</div>';
  126. $("body").append(html);
  127. $("#toolRadarPanel .popup-ct").dragmove($('#toolRadarPanel'));
  128. $('#toolRadarPanel .sure').click(function () {
  129. var number1 = $('#toolRadarPanel #viewHeight').val();
  130. var number2 = $('#toolRadarPanel #radius').val();
  131. if (isNaN(Number(number1))) {
  132. ONEMAP.C.publisher.publish({
  133. type: 'warning',
  134. message: '请输入正确的高度!'
  135. }, 'noteBar::add');
  136. return
  137. }
  138. if (isNaN(Number(number2))) {
  139. ONEMAP.C.publisher.publish({
  140. type: 'warning',
  141. message: '请输入正确的半径 !'
  142. }, 'noteBar::add');
  143. return
  144. }
  145. map3DViewer.radar({
  146. action: "start",
  147. radius: number2, //雷达半径
  148. circleTangle: 10, //雷达密度1,5,10·····90
  149. height: number1, //中心点高度,
  150. altitudeMode: 1, //1贴地 2水平切球
  151. properties: {
  152. // title: '雷达',
  153. color: "#00ff00",
  154. weight: 1,
  155. opacity: 1,
  156. fillColor: "#ff6600",
  157. fillOpacity: 0.5,
  158. },
  159. });
  160. $('#toolRadarPanel').remove();
  161. })
  162. $('#toolRadarPanel .cancel,#toolRadarPanel .close').click(function () {
  163. // 退出
  164. ONEMAP.C.publisher.publish({
  165. modName: 'tool3DRadar'
  166. }, 'tools:active');
  167. })
  168. }
  169. return ONEMAP.M.tool3DRadar = {
  170. init: init
  171. }
  172. })