/** * [ONEMAP.M.projectController] * @return {[object]} */ define(['modDir/service/cartodbParse'], function (cartodbParseF) { /** * 初始化并订阅事件 * @return {[type]} [description] */ /** * 模块数据 用于数据存储和外部调用 * @type {Object} * 数据存放 */ var modValue = { } /** * 状态值 * @type {Boolean} * @default false * @private */ var status = { initialized: false, isShowChild: false, connect: false, webSocketState: false, ztContent: false }; var video_stus = { //渲染div的id id: "", //时间轴移动的位置 x: 0, //播放的当前页数 nowPage: 0, //播放总页数 dataCount: 0, //每秒移动的像素 perTime: "", //播放间隔 intervalTime: 5200, //定时事件ID intervalId: null, //启报时间组 qbTime: [], //vti vti: [], //urls urls: [], zixiang: [], guids: [] } function init() { if (!status.initialized) { subscribe(); bindEvent(); status.initialized = true; status.ztContent = true; // $("#heaven").parent().find(".menu-content").show(); } setDixingList(); if (status.ztContent) { $("#menu .ztContent").addClass("active"); $(this).addClass("active"); status.ztContent = false; } else { $("#menu .ztContent").removeClass("active"); $(this).removeClass("active"); status.ztContent = true; } ONEMAP.C.publisher.publish({ modName: 'heaven' }, 'menuListClick'); } function bindEvent() { $("#layerControlMenu .sxlayer .close").on("click", function () { removeSxLayer() }) var myFunc = function () { removeSxLayer() $("#layerControlMenu .clearLayer").unbind("click", myFunc) }; $("#layerControlMenu .clearLayer").bind("click", myFunc) $("#layerControlMenu .sxlayer input[type='checkbox']").on("click", function () { if ($("#layerControlMenu .sxlayer .eye").hasClass('checkTrue')) { $(".shixu-time-box").hide(); } else { $(".shixu-time-box").show(); } }) } function removeSxLayer() { for (var i = 0; i < video_stus.guids.length; i++) { map23DControl.tileLayer({ action: 'remove', guid: video_stus.guids[i] }) } if ($("#menu .dzzy section .sectionbg .translate").text().indexOf("时序图层") > -1) { $("#menu .dzzy section .meun-checkBox").removeClass("menu-select").addClass("menu-select-no") } // $("#layerControlMenu .sxlayer").remove(); // map2DViewer.map.remove('BJDXAP2016') map2DViewer.map.setZoomScope(1, 19); $(".shixu-time-box").hide(); } //添加地形图组 function setDixingList() { $(".ztContent").html(""); var zt = $(".ztContent"); var category = ONEMAP.D.globalSettingData.map2DThematicCategory; for (var i = 0; i < category.length; i++) { var liHtml = $('
' + category[i] + '
') // 可对category[i]进行识别 if (category[i] == "城市地质") { liHtml = $('
' + category[i] + '
') } var linkcontent = $(''); $(ONEMAP.D.globalSettingData.map2DThematicSetting).each(function (index, el) { if (el.category === category[i]) { var thematicLink = $(''); thematicLink.bind('click', el, function (e) { var mc = thematicLink.find(".meun-checkBox"); // console.log(el); if (!mc.hasClass("menu-select-no")) { mc.removeClass('menu-select').addClass("menu-select-no"); if (ONEMAP.M.toolWeatherMap) { ONEMAP.M.toolWeatherMap.remove(); } // 从我的图层中移除 var guid = mc.prev().attr("layer"); // console.log(guid); var options = { action: "remove", DOMid: guid } ONEMAP.C.publisher.publish({ type: el.legend }, 'legend:remove'); ONEMAP.M.myLayers.myLayerControl(options); // 移除数据层 removeCurrentOverLayerGai(guid); if (typeof (e.data['max_zoom']) != "undefined") { ONEMAP.M.myLayers.zoomActions("remove", e.data['min_zoom'], e.data['max_zoom']); } else { ONEMAP.M.myLayers.zoomActions("remove", 1, 19); } //时序 if (thematicLink.parents().filter("section").find(".sectionbg .translate").text().indexOf("时序图层") > -1) { $("#layerControlMenu .sxlayer .close").click(); // setTimeout(function(){ // mc.removeClass('menu-select').addClass("menu-select-no"); // },800) // removeSxLayer(); } } else { // console.log(el); // console.log(el.type); // console.log(e.data.type); mc.removeClass('menu-select-no').addClass("menu-select"); // 专题一张图自动跳转二维 ONEMAP.C.publisher.publish('2D', 'layout::mapStyle'); if (el.type == "otherOrigin") { el.guid = map23DControl.buildGuid("zhuanTi"); } if (ONEMAP.M.toolWeatherMap) { ONEMAP.M.toolWeatherMap.remove(); } // removeCurrentOverLayer(); if (e.data.type === "weatherMap") { //获取云图图集列表数据 var weatherData; $.ajax({ type: 'get', dataType: 'jsonp', url: el.productUrl + '/production/product_category?production_id=' + el.guid, beforeSend: ONEMAP.V.loading.load(), success: function (data) { weatherData = data; //添加云图控件 addWeatherControl(weatherData, e.data); }, error: function (data) { //console.log("有点小失败"); }, completer: ONEMAP.V.loading.loaded() }) // $('#userThematicList .selected').removeClass('selected'); // mc.addClass('selected'); } else if (e.data.type === "thematicOrigin") { // console.log("thema"); // console.log(e.data); // 专题一张图(中国地图、海图等) var layerLength = ONEMAP.M.myLayers.checkLength(); if (layerLength < map23DConfig.layerMaxLength) { url2D = e.data.url + '/' + e.data.guid + '?l={z}&x={x}&y={y}'; url3D = e.data.url + '/' + e.data.guid + '?z={z}&x={x}&y={y}'; //url3D = e.data.url + '/' + e.data.guid + '?z=%d&x=%d&y=%d'; modValue.currentOverLayerGuid = map23DControl.tileLayer({ action: 'add', layer: { url2D: url2D, url3D: url3D, imageType: 'png', name: e.data.name, minZoom: e.data.min_zoom || 1, maxZoom: e.data.max_zoom || 19, guid: e.data.guid } }) // 添加到我的图层 if (el.legend) { var options = { action: "add", DOM: { guid: modValue.currentOverLayerGuid, type: el.type, name: el.name, legend: el.legend }, mod: el.type } } else { var options = { action: "add", DOM: { guid: modValue.currentOverLayerGuid, type: el.type, name: el.name }, mod: el.type } } mc.prev().attr("layer", options.DOM.guid); mc.prev().attr("class", "zt-cbx " + options.DOM.guid); modValue.DOMid = ONEMAP.M.myLayers.myLayerControl(options); // 添加信息到“我的图层” ONEMAP.C.publisher.subscribe(layerAction, options.DOM.guid); thematicControl( map2DViewer.layers[modValue.currentOverLayerGuid], { data: e.data, showFavBtn: false, closeCallback: function () { removeCurrentOverLayer(); $('#userThematicList .selected').removeClass('selected'); } }) ONEMAP.D.overLayerCount++; map2DViewer.map.setZoomScope(e.data['min_zoom'], e.data['max_zoom']); // console.log(e.data); // console.log(e.data['max_zoom']); if (typeof (e.data['max_zoom']) != "undefined") { ONEMAP.M.myLayers.zoomActions("add", e.data['min_zoom'], e.data['max_zoom'], map23DData.view.center['lat'], map23DData.view.center['lng'], e.data['zoom'], e.data.name); } else { ONEMAP.M.myLayers.zoomActions("add", 1, 19, map23DData.view.center['lat'], map23DData.view.center['lng'], e.data['zoom'], e.data.name); } // ONEMAP.M.myLayers.zoomActions("add",e.data['min_zoom'], e.data['max_zoom']); map23DControl.setView({ center: { lat: e.data['center'].lat, lng: e.data['center'].lng }, zoom: e.data['zoom'], tilt: 0 }); // 针对磁场分布图的透明度预设置 if (e.data.guid == "CCFBT") { ONEMAP.C.publisher.publish({ action: 'opacity', options: { opacity: 0.5 }, guid: options.DOM.guid }, options.DOM.guid); $("#layerControlMenu .myLayers .op .yuan").css("left", "35px"); $("#layerControlMenu .myLayers .op .chang").css("width", "35px"); } } else { $(this).find(".meun-checkBox").removeClass("menu-select").addClass("menu-select-no"); ONEMAP.C.publisher.publish({ type: 'warning', message: '图层数量已达上限' }, 'noteBar::add'); return false; } // $('#userThematicList .selected').removeClass('selected'); // mc.addClass('selected'); //E 优化 } else if (e.data.type === "vectorOrigin") { var cartodbF = new cartodbParseF(); cartodbF.getVizInfo({ vizUrl: e.data['url'] }, function (tileData) { var tdTileLayerUrl = tileData['templateUrl'].replace('{z}/{x}/{y}', '%d/%d/%d'); modValue.currentOverLayerGuid = map23DControl.tileLayer({ action: 'add', layer: { url2D: tileData['templateUrl'], url3D: tdTileLayerUrl, imageType: 'png', name: e.data.name, minZoom: e.data.min_zoom || 1, maxZoom: e.data.max_zoom || 19 } }) map2DViewer.layers[modValue.currentOverLayerGuid]['utfgrids'] = []; //添加utfgrid _.each(tileData.utfgridUrl, function (el, index) { var aGridLayer = new L.UtfGrid(el + '?callback={cb}'); map2DViewer.layers[modValue.currentOverLayerGuid]['utfgrids'].push(aGridLayer); aGridLayer.layerNum = index; aGridLayer.on('click', function (e) { L.DomEvent.stopPropagation(e); if (e.data) { var layerNum = e.target._map._layers[e.target._leaflet_id].layerNum; $.ajax({ url: tileData.serverApiUrl + '/v1/map/' + tileData.layergroupid + '/' + layerNum + '/attributes/' + e.data.cartodb_id, type: 'GET', dataType: 'jsonp' }) .done(function (data) { if (data) { var popupContent = $('
'); _.each(data, function (pel, pindex) { popupContent.append('
' + pindex + ':' + pel + '
') }); var popup = L.popup() .setLatLng(e.latlng) .setContent(popupContent.get(0)) .openOn(map2DViewer.map); } }); } }); aGridLayer.addTo(map2DViewer.map); }); // 添加到我的图层 var options = { action: "add", DOM: { guid: modValue.currentOverLayerGuid, type: el.type, name: el.name, legend: el.legend }, mod: el.type } mc.prev().attr("layer", options.DOM.guid); mc.prev().attr("class", "zt-cbx " + options.DOM.guid); modValue.DOMid = ONEMAP.M.myLayers.myLayerControl(options); // 添加信息到“我的图层” ONEMAP.C.publisher.subscribe(layerAction, options.DOM.guid); thematicControl( map2DViewer.layers[modValue.currentOverLayerGuid], { data: e.data, showFavBtn: false, closeCallback: function () { removeCurrentOverLayer(); $('#userThematicList .selected').removeClass('selected'); } }) ONEMAP.D.overLayerCount++; map2DViewer.map.setZoomScope(e.data['min_zoom'], e.data['max_zoom']); map23DControl.setView({ center: { lat: e.data['center'].lat, lng: e.data['center'].lng }, zoom: e.data['zoom'], tilt: 0 }) // $('#userThematicList .selected').removeClass('selected'); // mc.addClass('selected'); //E 优化 }); } else if (e.data.type === "shixuOrigin") { //时序图层 // console.log(e.data); var zixiangobj = e.data.zixiang; zixiangobj.sort(function (a, b) { return a.sxTime - b.sxTime; }) $("#layerControlMenu .sxlayer .close").click(); mc.removeClass('menu-select-no').addClass("menu-select"); var lasttime = zixiangobj.length; video_stus.data = e.data; video_stus.intervalTime = e.data.intervalTime; video_stus.qbTime = []; video_stus.vti = []; video_stus.urls = []; if ($(".shixu-time-box").length < 2) { $("#wrapper").append($(".shixu-time-box")); } $(".shixu-time-box").show(); $(".shixu-time-box .sx-title-left-c .title").text(e.data.name); $(".shixu-time-box .sx-title-left-c .time").text(zixiangobj[0].sxTime); $(".shixu-time-box .sx-video-progress-nowtime").text(1); $(".shixu-time-box .sx-video-progress-lasttime").text(lasttime); for (var i = 0; i < lasttime; i++) { video_stus.qbTime.push(zixiangobj[i].sxTime); video_stus.urls.push(zixiangobj[i].sxUrl); } bindSxPlayEvents(); } else { // 天地图 // console.log("other 天地图"); var layerLength = ONEMAP.M.myLayers.checkLength(); if (layerLength < map23DConfig.layerMaxLength) { var tdTileLayerUrl = e.data['url'].replace('?x={x}&y={y}&z={z}', '?z=%d&x=%d&y=%d'); tdTileLayerUrl = tdTileLayerUrl.replace('?z={z}&x={x}&y={y}', '?z=%d&x=%d&y=%d'); tdTileLayerUrl = tdTileLayerUrl.replace('{z}/{y}/{x}', '%d/%d/%d'); modValue.currentOverLayerGuid = map23DControl.tileLayer({ action: 'add', layer: { url2D: e.data['url'], url3D: tdTileLayerUrl, imageType: 'png', name: e.data.name, minZoom: e.data.min_zoom || 1, maxZoom: e.data.max_zoom || 19 } }) // 添加到我的图层 if (el.legend) { var options = { action: "add", DOM: { guid: modValue.currentOverLayerGuid, type: el.type, name: el.name, legend: el.legend }, mod: el.type } } else { var options = { action: "add", DOM: { guid: modValue.currentOverLayerGuid, type: el.type, name: el.name }, mod: el.type } } mc.prev().attr("layer", options.DOM.guid); mc.prev().attr("class", "zt-cbx " + options.DOM.guid); modValue.DOMid = ONEMAP.M.myLayers.myLayerControl(options); // 添加信息到“我的图层” ONEMAP.C.publisher.subscribe(layerAction, options.DOM.guid); //S 优化 //添加图层透明度控件 // overLayerOpacityControl = new L.Control.LayerOpacity( // map2DViewer.layers[modValue.currentOverLayerGuid], { // showFavBtn: false, // closeCallback: function() { // removeCurrentOverLayer(); // $('#userThematicList .selected').removeClass('selected'); // } // } // ).addTo(map2DViewer.map); thematicControl( map2DViewer.layers[modValue.currentOverLayerGuid], { data: e.data, showFavBtn: false, closeCallback: function () { removeCurrentOverLayer(); $('#userThematicList .selected').removeClass('selected'); } }) ONEMAP.D.overLayerCount++; map2DViewer.map.setZoomScope(e.data['min_zoom'], e.data['max_zoom']); if (typeof (e.data['max_zoom']) != "undefined") { ONEMAP.M.myLayers.zoomActions("add", e.data['min_zoom'], e.data['max_zoom'], map23DData.view.center['lat'], map23DData.view.center['lng'], e.data['zoom'], e.data.name); } else { ONEMAP.M.myLayers.zoomActions("add", 1, 19, map23DData.view.center['lat'], map23DData.view.center['lng'], e.data['zoom'], e.data.name); } map23DControl.setView({ center: { lat: e.data['center'].lat, lng: e.data['center'].lng }, zoom: e.data['zoom'], tilt: 0 }) } else { $(this).find(".meun-checkBox").removeClass("menu-select").addClass("menu-select-no"); ONEMAP.C.publisher.publish({ type: 'warning', message: '图层数量已达上限' }, 'noteBar::add'); return false; } // $('#userThematicList .selected').removeClass('selected'); // mc.addClass('selected'); //E 优化 } } }); thematicLink.appendTo(linkcontent); } }); liHtml.find('.sectionbg').bind('click', function () { $(this).parent().find('.linkContent').toggle(); if ($(this).hasClass('open')) { $(this).removeClass('open'); if ($(this).attr("id") == "cityGeology") { require(['modDir/menu/cityGeology'], function (cityGeology) { cityGeology.removeAll(); }); var layer = $("#cityGeology").attr("layer"); $("#layerControlMenu li." + layer).find(".close").click(); } } else { if ($(this).attr("id") == "cityGeology") { require(['modDir/menu/cityGeology'], function (cityGeology) { cityGeology.init(); }); } $(this).addClass('open'); $(this).parent().siblings().find('.linkContent').hide(); $(this).parent().siblings().find('.sectionbg').removeClass('open'); } }) linkcontent.appendTo(liHtml); // 可对category[i]进行识别 if (category[i] == "电磁" || category[i] == "磁力" || category[i] == "重力") { liHtml.appendTo($(".dqwlContent")); } else if (category[i] == "基础地质" || category[i] == "城市地质" || category[i] == "军事地质") { liHtml.appendTo($(".dzContent")); } else { liHtml.appendTo(zt); } // liHtml.appendTo($("#userThematicList")); } // zt.html($("#userThematicList").html()); // $("#userThematicList section").eq(0).find('.linkContent').show(); // $("#userThematicList section").eq(0).find('.sectionbg').addClass('open'); //更新滚动条 // $('#userThematic .ii-body').mCustomScrollbar('update'); } //添加三维专题图控制条 function thematicControl(layer, options) { modValue.thematicControlHtml = $("
" + "" + "
"); var cover_content = $("
"); cover_content.appendTo(modValue.thematicControlHtml); if (options.showFavBtn || !options.onlyShow) { var optionsWrap = $("
"); optionsWrap.appendTo(cover_content); } $("
名称:" + options.data.name + "
").appendTo(cover_content); if (options.atlas) { var atlasHtml = $("详情"); atlasHtml.appendTo(optionsWrap); atlasHtml.bind('click', function () {}); } if (options.showFavBtn) { var favBtnHtml = $("收藏"); favBtnHtml.appendTo(optionsWrap); favBtnHtml.bind('click', function () { }); } if (!options.onlyShow) { var closeBtnHtml = $("关闭"); closeBtnHtml.appendTo(optionsWrap); closeBtnHtml.bind('click', function () { options.closeCallback(); modValue.thematicControlHtml.remove(); }) } modValue.thematicControlHtml.appendTo($('#thematicControlContent')); }; function removeCurrentOverLayer() { if (modValue.currentOverLayerGuid) { modValue.thematicControlHtml.remove(); map23DControl.tileLayer({ action: 'remove', guid: modValue.currentOverLayerGuid }) modValue.currentOverLayerGuid = null; // map2DViewer.map.removeControl(overLayerOpacityControl); overLayerOpacityControl = null; } ONEMAP.D.overLayerCount--; if (ONEMAP.D.overLayerCount == 0) { map2DViewer.map.setZoomScope(1, 19); } } function removeCurrentOverLayerGai(guid) { if (guid) { modValue.thematicControlHtml.remove(); map23DControl.tileLayer({ action: 'remove', guid: guid }) guid = null; // map2DViewer.map.removeControl(overLayerOpacityControl); overLayerOpacityControl = null; } ONEMAP.D.overLayerCount--; if (ONEMAP.D.overLayerCount == 0) { map2DViewer.map.setZoomScope(1, 19); } } //按钮绑定事件 function bindSxPlayEvents() { timeChangeEvent(0); var proWidth = $(".sx-video-progress").width(); var vtiLength = parseInt($(".sx-video-progress-lasttime").text()); for (var i = 0; i < vtiLength; i++) { video_stus.vti.push(i + 1); } video_stus.perTime = proWidth / (video_stus.vti.length - 1); //上一个 $(".sx-video-btn-back").off("click").on("click", function () { back(); }); //播放 $(".sx-video-btn-play").off("click").on("click", function () { if (!video_stus.intervalId) { //播放 play(); } else { //暂停 stop(); } }); //下一个 $(".sx-video-btn-next").off("click").on("click", function () { next(); }); //进度轴时间点 $(".sx-video-progress_btn").off("mousedown").on("mousedown", function (event) { stop(); var yuanleft = 0; var leftVal = event.clientX - this.offsetLeft - event.offsetX; var width = $(".sx-video-progress").width(); var pt = video_stus.perTime / 2; document.onmousemove = function (event) { var event = event || window.event; yuanleft = event.clientX - leftVal; if (yuanleft < 0) yuanleft = 0; if (yuanleft > width) yuanleft = width; var index = ((yuanleft + pt) / video_stus.perTime) >> 0; if (index != video_stus.nowPage) setVti(index); window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty(); } document.onmouseup = function () { document.onmousemove = null; //弹起鼠标不做任何操作 } }) } function next() { stop(); //点击下一时次按钮时,先停止播放 setVti(video_stus.nowPage + 1); } function back() { stop(); //点击上一时次按钮时,先停止播放 setVti(video_stus.nowPage - 1); } var restart = false; function play() { if (restart) { video_stus.nowPage = 0; $(".sx-video-progress_btn").css("left", -10 + "px"); $(".sx-video-progress-nowtime").html(1); $("#wrapper .sx-title-left-c .time").html(video_stus.qbTime[0]); timeChangeEvent(0); restart = false; } if (video_stus.nowPage == video_stus.vti.length - 1) return; if (video_stus.intervalId) stop(); $(".sx-video-btn-play").removeClass("sx-video-play-img"); $(".sx-video-btn-play").addClass("sx-video-parse-img"); video_stus.intervalId = window.setInterval(playNext, video_stus.intervalTime); } function playNext() { setVti(video_stus.nowPage + 1); if (video_stus.nowPage >= video_stus.vti.length - 1) { stop(); restart = true; return; } } function stop() { if (!video_stus.intervalId) return; $(".sx-video-btn-play").removeClass("sx-video-parse-img"); $(".sx-video-btn-play").addClass("sx-video-play-img"); clearInterval(video_stus.intervalId); video_stus.intervalId = null; } function setVti(index) { //设置当前显示的vti // console.log(index); // console.log(video_stus.perTime) if (isNaN(index)) index = 0; if (index >= video_stus.vti.length) return; if (index < 0) return; video_stus.nowPage = index; video_stus.x = video_stus.nowPage * video_stus.perTime; $(".sx-video-progress_btn").css("left", video_stus.x - 12); $(".sx-video-progress-nowtime").html(video_stus.vti[video_stus.nowPage]); $(".sx-title-left-c span.time").html(video_stus.qbTime[index]); btnDisabled(); timeChangeEvent(index); } //调整按钮样式 function btnDisabled() { if (video_stus.nowPage > 0) { $(".sx-video-btn-next").removeClass("sx-video-next-img"); $(".sx-video-btn-next").addClass("sx-video-next-img-blue"); $(".sx-video-btn-back").removeClass("sx-video-back-img"); $(".sx-video-btn-back").addClass("sx-video-back-img-blue"); if (video_stus.nowPage >= video_stus.vti.length - 1) { $(".sx-video-btn-next").removeClass("sx-video-next-img-blue"); $(".sx-video-btn-next").addClass("sx-video-next-img"); } } else { $(".sx-video-btn-next").removeClass("sx-video-next-img"); $(".sx-video-btn-next").addClass("sx-video-next-img-blue"); $(".sx-video-btn-back").removeClass("sx-video-back-img-blue"); $(".sx-video-btn-back").addClass("sx-video-back-img"); } } //加载图像 function timeChangeEvent(index) { // 大兴机场示例 var layerLength = ONEMAP.M.myLayers.checkLength(); if (layerLength < map23DConfig.layerMaxLength) { var url2D = video_stus.urls[index] + '?l={z}&x={x}&y={y}'; var vguid = video_stus.urls[index].split("v1.0/")[1]; var vname = $("#wrapper .sx-title-left-c .title").text(); if (index == 0 && $("#layerControlMenu .sxlayer").length < 1) { modValue.currentOverLayerGuid = map23DControl.tileLayer({ action: 'add', layer: { url2D: url2D, url3D: url2D, imageType: 'png', name: vname, minZoom: 1, maxZoom: 19, guid: vguid } }) map23DControl.setView({ center: { lat: video_stus.data.center.lat, lng: video_stus.data.center.lng }, zoom: video_stus.data.zoom, tilt: 0 }); // 添加到我的图层 var options = { action: "add", DOM: { guid: modValue.currentOverLayerGuid, type: 'sxlayer', name: vname }, mod: 'sxlayer' } modValue.DOMid = ONEMAP.M.myLayers.myLayerControl(options); bindEvent(); ONEMAP.C.publisher.subscribe(layerAction, options.DOM.guid); } else { map23DControl.tileLayer({ action: 'update', layer: { url2D: url2D, url3D: url2D, imageType: 'png', name: vname, minZoom: 18, maxZoom: 19, guid: vguid }, guid: modValue.currentOverLayerGuid }) } video_stus.guids.push(modValue.currentOverLayerGuid); } else { // $(this).find(".meun-checkBox").removeClass("menu-select").addClass("menu-select-no"); ONEMAP.C.publisher.publish({ type: 'warning', message: '图层数量已达上限' }, 'noteBar::add'); return false; } } /** * 设置界面 */ function setLayout() { } /** * 界面重置 * @return {[type]} [description] */ function layoutResize(options) { if (options.modName != "heaven") { remove(); } else { if (status.isShowChild) { remove(); $("#menu #heaven").removeClass('active'); } else { $("#menu #heaven").addClass('active'); status.isShowChild = true; } } } /** * 模块移除 * @return {[type]} [description] */ function remove() { //取消订阅 unSubscribe(); $("#menu #heaven").removeClass('active'); status.isShowChild = false; } /** * 注册订阅 * @type {Function} * 推送:ONEMAP.C.publisher.publish(options,'moduleName::type'); * 订阅:ONEMAP.C.publisher.subscribe(layoutResize,'sideBarLayoutChange'); */ function subscribe() { ONEMAP.C.publisher.subscribe(layoutResize, 'menuListClick'); ONEMAP.C.publisher.subscribe(removeSxLayer, 'cleanMap'); } /** * 取消订阅 * @type {Function} * 取消订阅:ONEMAP.C.publisher.unSubscribe(layoutResize,'sideBarLayoutChange'); */ function unSubscribe() { } // 监听图层操作动作 function layerAction(options) { // console.log(options); // console.log(modValue.ids); if (options.action == "remove") { // console.log("remove"); removeLayer(options.guid); } else if (options.action == "opacity") { var opt = options.options.opacity; setOpacity(options.guid, opt); } else if (options.action == "up" || options.action == "down") { ONEMAP.M.myLayerActions.changeFloor(); } } // 更改层级 function changeFloor() { var li = $("#layerControlMenu .myLayers .mn-content li"); var layer = $("#mapHolder #map2DWrap .leaflet-layer"); var liLength = li.length; var zidArr = new Array(); for (var i = 0; i < liLength; i++) { zidArr.push(li.eq(i).attr("zid")); for (var j = 0; j < layer.length; j++) { if (layer.eq(j).attr("zid") == zidArr[i]) { layer.eq(j).css("z-index", layer.length - i); } } } } // 设置透明度 function setOpacity(zid, opt) { map23DControl.tileLayer({ action: 'update', guid: zid, layer: { opacity: opt } }) } // 添加图层 function addLayer(data) { $("#layerControlMenu .mn-content p.tip-none").hide(); //添加到23D地图上 modValue.currentOverLayerGuid = map23DControl.tileLayer({ action: 'add', layer: { url2D: onemapUrlConfig.thematicTileUrl + '/' + data.guid + '?l={z}&x={x}&y={y}', url3D: onemapUrlConfig.thematicTileFo3DUrl + '/' + data.guid + '?z=%d&x=%d&y=%d', minZoom: data['min_zoom'], maxZoom: data['max_zoom'], maxNativeZoom: data['max_zoom'], attribution: '', opacity: 1, imageType: 'png', name: data.name, guid: data.guid } }) map23DControl.setView({ center: { lat: data['center_lat'], lng: data['center_lon'] }, zoom: data['zoom'] }) map2DViewer.map.setZoomScope(data['min_zoom'], data['max_zoom']); } // 移除图层 function removeLayer(data) { if (data) { if (modValue.thematicControlHtml) { modValue.thematicControlHtml.remove(); } map23DControl.tileLayer({ action: 'remove', guid: data }) data = null; // map2DViewer.map.removeControl(overLayerOpacityControl); overLayerOpacityControl = null; $(".shixu-time-box").hide(); } ONEMAP.D.overLayerCount--; if (ONEMAP.D.overLayerCount == 0) { map2DViewer.map.setZoomScope(1, 19); } } // // 更改层级 // function changeFloor(){ // var li = $("#layerControlMenu .myLayers .mn-content li"); // var layer = $("#mapHolder #map2DWrap .leaflet-layer"); // var liLength = li.length; // var zidArr = new Array(); // for(var i=0;i