123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- 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.lookAroundAnalysis({
- action: "add",
- callback: callback
- })
- }
- ONEMAP.C.publisher.publish({
- modName: 'tool3DLookAroundAnalysis'
- }, '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.lookAroundAnalysis({
- action: "remove"
- })
- $('#toolLookAroundAnalysisPanel').remove();
- if ($(".tools-lookAroundAnalysis").hasClass('cur')) {
- $(".tools-lookAroundAnalysis").removeClass('cur');
- }
- }
- /**
- * 3D环视 加载/移除 注册事件
- */
- function remove(options) {
- if (options.modName != 'tool3DLookAroundAnalysis') {
- if (options.modName == 'cleanMap') {
- clear();
- }
- removeAndClear();
- $(".tools-lookAroundAnalysis").removeClass('cur');
- } else {
- if ($(".tools-lookAroundAnalysis").hasClass('cur')) {
- $(".tools-lookAroundAnalysis").removeClass('cur');
- removeAndClear();
- } else {
- $(".tools-lookAroundAnalysis").addClass('cur');
- addPopup();
- }
- }
- }
- /**
- * 移除 3D环视
- */
- function removeAndClear() {
- map3DViewer.lookAroundAnalysis({
- action: "stop"
- })
- $('#toolLookAroundAnalysisPanel').remove();
- };
- /**
- * 清除绘制 3D环视
- */
- function clear(params) {
- map3DViewer.lookAroundAnalysis({
- action: "remove"
- })
- }
- /**
- * 3D环视分析后的回调
- */
- function callback() {
- // 退出
- ONEMAP.C.publisher.publish({
- modName: 'tool3DLookAroundAnalysis'
- }, 'tools:active');
- }
- // 添加 弹窗
- function addPopup() {
- var html = '<div id="toolLookAroundAnalysisPanel" 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>' +
- ' <button class="btn btn2 sure">确定</button>' +
- ' <button class="btn btn2 cancel">取消</button>' +
- ' </div>' +
- ' </div>' +
- ' </div>' +
- ' </div>' +
- '</div>';
- $("body").append(html);
- $("#toolLookAroundAnalysisPanel .popup-ct").dragmove($('#toolLookAroundAnalysisPanel'));
- $('#toolLookAroundAnalysisPanel .sure').click(function () {
- var number = $('#toolLookAroundAnalysisPanel #viewHeight').val();
- if (isNaN(Number(number))) {
- ONEMAP.C.publisher.publish({
- type: 'warning',
- message: '请输入正确的视高!'
- }, 'noteBar::add');
- return
- }
- map3DViewer.lookAroundAnalysis({
- action: "start",
- viewHeight: Number(number),
- angleInterval: 5
- })
- $('#toolLookAroundAnalysisPanel').remove();
- })
- $('#toolLookAroundAnalysisPanel .cancel,#toolLookAroundAnalysisPanel .close').click(function () {
- // 退出
- ONEMAP.C.publisher.publish({
- modName: 'tool3DLookAroundAnalysis'
- }, 'tools:active');
- })
- }
- return ONEMAP.M.tool3DLookAroundAnalysis = {
- init: init
- }
- })
|