123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- 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 = '<div id="toolRadarPanel" class="viewHeightPopup class3d">' +
- ' <iframe frameborder="0" class="cover-iframe"></iframe>' +
- ' <div class="cover-content">' +
- ' <div class="">' +
- ' <div class="popup-lt"></div>' +
- ' <div class="popup-lb"></div>' +
- ' <div class="popup-rt"></div>' +
- ' <div class="popup-rb"></div>' +
- ' <div class="popup-ct">' +
- ' <button type="button" class="close"></button>' +
- ' <h3>' + modValue.title + '</h3>' +
- ' </div>' +
- ' <div class="popup-cb">' +
- ' <div class="panel">' +
- ' <span>视高:</span>' +
- ' <input class="input" value="3" id="viewHeight" /><span>米</span></br>' +
- ' <span>半径:</span>' +
- ' <input class="input" value="3" id="radius" /><span>米</span>' +
- ' <button class="btn btn2 sure">确定</button>' +
- ' <button class="btn btn2 cancel">取消</button>' +
- ' </div>' +
- ' </div>' +
- ' </div>' +
- ' </div>' +
- '</div>';
- $("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
- }
- })
|