123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023 |
- /**
- * [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 = $('<section class="item"><div class="sectionbg"><span class="translate">' + category[i] + '</span></div></section>')
- // 可对category[i]进行识别
- if (category[i] == "城市地质") {
- liHtml = $('<section class="item"><div class="sectionbg" id="cityGeology"><span class="translate">' + category[i] + '</span></div></section>')
- }
- var linkcontent = $('<ul class="linkContent" style="display:none"></ul>');
- $(ONEMAP.D.globalSettingData.map2DThematicSetting).each(function (index, el) {
- if (el.category === category[i]) {
- var thematicLink = $('<li class="item thematic-layer-link"><div class="linkLibg"></div><input type="checkbox" class="zt-cbx"/><span class="meun-checkBox menu-select-no"></span><span class="translate" title="' + el.name + '">' + el.name + '</span></li>');
- 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 = $('<div></div>');
- _.each(data, function (pel, pindex) {
- popupContent.append('<div><strong>' + pindex + '</strong>:' + pel + '</div>')
- });
- 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 = $("<div class='thematicControl'>" +
- "<iframe frameborder='0' class='cover-iframe'></iframe>" +
- "</div>");
- var cover_content = $("<div class='cover-content'></div>");
- cover_content.appendTo(modValue.thematicControlHtml);
- if (options.showFavBtn || !options.onlyShow) {
- var optionsWrap = $("<div class='options-wrap'></div>");
- optionsWrap.appendTo(cover_content);
- }
- $("<div class='thematicName'>名称:" + options.data.name + "</div>").appendTo(cover_content);
- if (options.atlas) {
- var atlasHtml = $("<a class='info_Btntd'>详情</a>");
- atlasHtml.appendTo(optionsWrap);
- atlasHtml.bind('click', function () {});
- }
- if (options.showFavBtn) {
- var favBtnHtml = $("<a class='fav_abtntd'>收藏</a>");
- favBtnHtml.appendTo(optionsWrap);
- favBtnHtml.bind('click', function () {
- });
- }
- if (!options.onlyShow) {
- var closeBtnHtml = $("<a class='close_abtntd'>关闭</a>");
- 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<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);
- // }
- // }
- // }
- // }
- return ONEMAP.M.heaven = {
- init: init
- }
- });
|