define(function () { /** * 状态值 * @type {Boolean} * @default false * @private */ var status = { initialized: false, //是否初始化 }; /** * 模块数据 用于数据存储和外部调用 * @type {Object} * 数据存放 */ var modValue = { title: "雷达遮罩", }; /** * 3D 通视初始化 */ function init() { if (!status.initialized) { subscribe(); status.initialized = true; map3DViewer.radar({ action: "add", callback: callback }) } ONEMAP.C.publisher.publish({ modName: 'tool3DRadar' }, 'tools:active'); }; /** * 注册监听事件 */ function subscribe() { ONEMAP.C.publisher.subscribe(remove, 'tools:active'); ONEMAP.C.publisher.subscribe(clear, 'cleanMap'); ONEMAP.C.publisher.subscribe(removeEvent, 'change23D'); }; // 23D转换 function removeEvent() { map3DViewer.radar({ action: "remove" }) $('#toolRadarPanel').remove(); if ($(".tools-radar").hasClass('cur')) { $(".tools-radar").removeClass('cur'); } } /** * 雷达 加载/移除 注册事件 */ function remove(options) { if (options.modName != 'tool3DRadar') { if (options.modName == 'cleanMap') { clear(); } removeAndClear(); $(".tools-radar").removeClass('cur'); } else { if ($(".tools-radar").hasClass('cur')) { $(".tools-radar").removeClass('cur'); removeAndClear(); } else { $(".tools-radar").addClass('cur'); addPopup(); } } } /** * 移除 雷达 */ function removeAndClear() { map3DViewer.radar({ action: "stop" }) $('#toolRadarPanel').remove(); }; /** * 清除绘制 雷达 */ function clear() { map3DViewer.radar({ action: "remove" }) } /** * 雷达分析后的回调 */ function callback() { // 退出 ONEMAP.C.publisher.publish({ modName: 'tool3DRadar' }, 'tools:active'); } // 添加 弹窗 function addPopup() { var html = '
' + ' ' + '
' + '
' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + '
' + '
' + '
'; $("body").append(html); $("#toolRadarPanel .popup-ct").dragmove($('#toolRadarPanel')); $('#toolRadarPanel .sure').click(function () { var number1 = $('#toolRadarPanel #viewHeight').val(); var number2 = $('#toolRadarPanel #radius').val(); if (isNaN(Number(number1))) { ONEMAP.C.publisher.publish({ type: 'warning', message: '请输入正确的高度!' }, 'noteBar::add'); return } if (isNaN(Number(number2))) { ONEMAP.C.publisher.publish({ type: 'warning', message: '请输入正确的半径 !' }, 'noteBar::add'); return } map3DViewer.radar({ action: "start", radius: number2, //雷达半径 circleTangle: 10, //雷达密度1,5,10·····90 height: number1, //中心点高度, altitudeMode: 1, //1贴地 2水平切球 properties: { // title: '雷达', color: "#00ff00", weight: 1, opacity: 1, fillColor: "#ff6600", fillOpacity: 0.5, }, }); $('#toolRadarPanel').remove(); }) $('#toolRadarPanel .cancel,#toolRadarPanel .close').click(function () { // 退出 ONEMAP.C.publisher.publish({ modName: 'tool3DRadar' }, 'tools:active'); }) } return ONEMAP.M.tool3DRadar = { init: init } })