123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656 |
- /**
- * @fileoverview 全局设置 模块
- * @author Song.Huang
- * @version 1.0.0
- */
- define(['html!templates/user/userSetting',
- 'css!styles/user/userSetting'
- ], function (tplLayout) {
- /**
- * 模块数据 用于数据存储和外部调用
- * @type {Object}
- * 数据存放
- */
- var modValue = {}
- /**
- * 是否已经初始化
- * @type {Boolean}
- * @default false
- */
- var status = {
- initialized: false,
- //是否可以post数据 用于表单验证
- canPost: false
- };
- /**
- * 初始化
- * @type {Function}
- */
- function init(jiD) {
- if (!status.initialized) {
- setLayout();
- //bindEvent();
- status.initialized = true;
- } else {
- $("#globalSetting").show();
- }
- //设置zIndex 为最高
- //var zIndex = ONEMAP.M.sideBar.getZIndex();
- //$('#globalSetting').css({zIndex:zIndex});
- //ONEMAP.D.currentSideBarMod = 'userSetting';
- //开启侧栏
- //ONEMAP.C.publisher.publish('show','layout::sideBar');
- if (jiD == 3) {
- $(".left_header ul li").removeClass("active");
- $(".left_header ul li").eq(1).addClass("active");
- $("#map3DSetting").show();
- $("#map2DSetting").hide();
- }
- };
- /**
- * 设置界面
- */
- function setLayout() {
- $(tplLayout).appendTo($("body"));
- $("#globalSetting .panel-body .itemleft .left_header ul li").eq(0).addClass('active');
- $("#map2DSetting").show();
- $("#thematicSetting").addClass('active');
- $("#model3DSetting").addClass('active');
- // $("#IGoalsContentSetting").addClass('active');
- layoutResize();
- $(window).resize(function () {
- layoutResize();
- });
- if (ONEMAP.D.globalSettingData.mapSetting) {
- $('#mapLat').val(ONEMAP.D.globalSettingData.mapSetting.center.lat);
- $('#mapLng').val(ONEMAP.D.globalSettingData.mapSetting.center.lng);
- $('#mapZoom').val(ONEMAP.D.globalSettingData.mapSetting.zoom);
- $('#mapType').val(ONEMAP.D.globalSettingData.mapSetting.type);
- }
- buildDxForm();
- $("#map2DSettingInfoContent .thematicModelList").mCustomScrollbar({
- scrollInertia: 100
- });
- $("#thematicList ul").mCustomScrollbar({
- scrollInertia: 100
- });
- $("#globalSetting .panel-body").mCustomScrollbar({
- scrollInertia: 100
- });
- buildMxForm();
- $("#map3DSettingInfoContent .model3DModelList").mCustomScrollbar({
- scrollInertia: 100
- });
- $("#model3DList ul").mCustomScrollbar({
- scrollInertia: 100
- });
- buildThemativC();
- $("#map2DSettingInfoContent .thematicCategoryList").mCustomScrollbar({
- scrollInertia: 100
- });
- buildModelC();
- $("#map3DSettingInfoContent .model3DCategoryList").mCustomScrollbar({
- scrollInertia: 100
- });
- buildIGList();
- $("#IGoalsSettingInfoContent .iGItemList").mCustomScrollbar({
- scrollInertia: 100
- });
- buildIGCa();
- $("#IGoalsSettingInfoContent .iGItemCList").mCustomScrollbar({
- scrollInertia: 100
- });
- buildKuozhan();
- bindEvent();
- }
- /**
- * 分类保存显示
- */
- function reSetLayout() {
- if (ONEMAP.D.globalSettingData.mapSetting) {
- $('#mapLat').val(ONEMAP.D.globalSettingData.mapSetting.center.lat);
- $('#mapLng').val(ONEMAP.D.globalSettingData.mapSetting.center.lng);
- $('#mapZoom').val(ONEMAP.D.globalSettingData.mapSetting.zoom);
- $('#mapType').val(ONEMAP.D.globalSettingData.mapSetting.type);
- }
- buildDxForm();
- $("#map2DSettingInfoContent .thematicModelList").mCustomScrollbar({
- scrollInertia: 100
- });
- $("#thematicList ul").mCustomScrollbar({
- scrollInertia: 100
- });
- $("#globalSetting .panel-body").mCustomScrollbar({
- scrollInertia: 100
- });
- buildMxForm();
- $("#map3DSettingInfoContent .model3DModelList").mCustomScrollbar({
- scrollInertia: 100
- });
- $("#model3DList ul").mCustomScrollbar({
- scrollInertia: 100
- });
- buildThemativC();
- $("#map2DSettingInfoContent .thematicCategoryList").mCustomScrollbar({
- scrollInertia: 100
- });
- buildModelC();
- $("#map3DSettingInfoContent .model3DCategoryList").mCustomScrollbar({
- scrollInertia: 100
- });
- buildIGList();
- $("#IGoalsSettingInfoContent .iGItemList").mCustomScrollbar({
- scrollInertia: 100
- });
- buildIGCa();
- $("#IGoalsSettingInfoContent .iGItemCList").mCustomScrollbar({
- scrollInertia: 100
- });
- bindEvent();
- };
- /**
- * 界面重置
- * @return {[type]} [description]
- */
- function layoutResize() {
- //$('#map2DSettingInfoContent .body').css({height:$(window).height()-145-$("#map2DForm").height()});
- //$('#mxList .body').css({height:$(window).height()-145-$("#map2DForm").height()});
- $("#globalSetting .panel-body").css({
- height: $(window).height() - 100
- });
- $("#globalSetting .panel-body .itemleft").css({
- height: $(window).height() - 100
- });
- $("#globalSetting .panel-body .itemright").css({
- height: $(window).height() - 100
- });
- $("#thematicList").css({
- height: $(window).height() - 360
- });
- $("#thematicList .listContent").css({
- height: $("#thematicList").height() - 30
- })
- $("#model3DList").css({
- height: $(window).height() - 360
- });
- $("#model3DList .listContent").css({
- height: $("#model3DList").height() - 30
- })
- $("#iGNameList").css({
- height: $(window).height() - 200
- });
- $("#iGNameList .listContent").css({
- height: $("#model3DList").height() - 30
- })
- }
- /**
- * 获取扩展服务
- * @return {[type]} [description]
- */
- function buildKuozhan() {
- // var kz = onemapUrlConfig.defaultGlobalSettingData.kuozhanLink;
- if (ONEMAP.D.globalSettingData.kuozhanLink) {
- var kz = ONEMAP.D.globalSettingData.kuozhanLink;
- // console.log(kz);
- for (var i = 0, l = kz.length; i < l; i++) {
- var title = kz[i].title;
- var link = kz[i].link;
- var liDom = $('<li><p><span>名称:</span><input type="text" value="' + title + '" name="title"></p><p><span>链接:</span><input type="text" value="' + link + '" class="linkAddr"></p><button>删除</button></li>');
- liDom.appendTo($("#kzList"));
- }
- }
- };
- /**
- * 界面事件绑定
- * @return {[type]} [description]
- */
- function bindEvent() {
- //添加拓展服务
- $(".add-kz").bind("click", function () {
- var liDom = $('<li><p><span>名称:</span><input type="text" name="title"></p><p><span>链接:</span><input type="text" class="linkAddr"></p><button>删除</button></li>');
- liDom.appendTo($("#kzList"));
- $("#kzList button").bind("click", function () {
- $(this).parent().remove();
- })
- })
- $("#kzList button").bind("click", function () {
- $(this).parent().remove();
- })
- $(".chhoostListContent").on('mouseleave', $("#globalSetting"), function () {
- $(".chhoostListContent").hide();
- })
- $("#globalSetting .panel-footer .sure").unbind('click').bind('click', function () {
- saveSetting();
- });
- $("#globalSetting .panel-header .closeSetting").unbind('click').bind('click', function () {
- $("#globalSetting").hide();
- })
- //面板切换
- $("#globalSetting .panel-body .itemleft .left_header ul li").unbind('click').bind('click', function () {
- if ($(this).hasClass('active')) {
- return false;
- } else {
- var contentId = $(this).attr('tab');
- $(this).addClass('active');
- $(this).siblings().removeClass('active');
- $("#" + contentId).show();
- $("#" + contentId).siblings().hide();
- $("#" + contentId + "InfoContent").show();
- $("#" + contentId + "InfoContent").siblings().hide();
- }
- })
- $("#thematicSetting").unbind('click').bind('click', function () {
- $(".thematicModelList").show();
- $(".thematicCategoryList").hide();
- $("#thematicSetting").addClass('active');
- $("#thematicCategorySetting,#kuozhanSetting").removeClass('active');
- $("#thematicList .add-new").show();
- $("#thematicList .add-newCa,.kuozhanList,#thematicList .add-kz").hide();
- })
- $("#thematicCategorySetting").unbind('click').bind('click', function () {
- $(".thematicModelList").hide();
- $(".thematicCategoryList").show();
- $("#thematicSetting,#kuozhanSetting").removeClass('active');
- $("#thematicCategorySetting").addClass('active');
- $("#thematicList .add-new,.kuozhanList,#thematicList .add-kz").hide();
- $("#thematicList .add-newCa").show();
- })
- $("#kuozhanSetting").unbind('click').bind('click', function () {
- $(".kuozhanList,#thematicList .add-kz").show();
- $(".beforelist,#thematicList .beforelink").hide();
- $(".beforebtn").removeClass('active');
- $("#kuozhanSetting").addClass('active');
- })
- $("#model3DSetting").unbind('click').bind('click', function () {
- $(".model3DModelList").show();
- $(".model3DCategoryList").hide();
- $("#model3DSetting").addClass('active');
- $("#model3DCategorySetting").removeClass('active');
- $("#model3DList .add-new").show();
- $("#model3DList .add-newb").show();
- $("#model3DList .add-newCa").hide();
- })
- $("#model3DCategorySetting").unbind('click').bind('click', function () {
- $(".model3DModelList").hide();
- $(".model3DCategoryList").show();
- $("#model3DSetting").removeClass('active');
- $("#model3DCategorySetting").addClass('active');
- $("#model3DList .add-new").hide();
- $("#model3DList .add-newb").hide();
- $("#model3DList .add-newCa").show();
- })
- // $("#IGoalsContentSetting").unbind('click').bind('click', function () {
- // $(".iGItemList").show();
- // $(".iGItemCList").hide();
- // $("#IGoalsContentSetting").addClass('active');
- // $("#IGoalsCategorySetting").removeClass('active');
- // $("#iGNameList .add-new").show();
- // $("#iGNameList .add-newCa").hide();
- // })
- // $("#IGoalsCategorySetting").unbind('click').bind('click', function () {
- // $(".iGItemList").hide();
- // $(".iGItemCList").show();
- // $("#IGoalsContentSetting").removeClass('active');
- // $("#IGoalsCategorySetting").addClass('active');
- // $("#iGNameList .add-new").hide();
- // $("#iGNameList .add-newCa").show();
- // })
- $('#thematicList .add-new').unbind('click').bind('click', function () {
- $(".bacover").show();
- $("#map2DOrigin").show();
- });
- $("#map2DOrigin .originSure").unbind('click').bind('click', function () {
- $(".bacover").hide();
- $("#map2DOrigin").hide();
- var type = $("#map2DOrigin .map2DOrigin").val();
- addNewDxForm(type);
- })
- $("#map2DOrigin .originCancel").unbind('click').bind('click', function () {
- $(".bacover").hide();
- $("#map2DOrigin").hide();
- })
- $('#map2DSettingInfoContent .delete').unbind('click').bind('click', function (e) {
- if (window.confirm('确定删除?')) {
- var el = e.target ? e.target : e.srcElement;
- $(el).parent().remove();
- $("#map2DSettingInfoContent .thematicModelList").mCustomScrollbar('update');
- }
- });
- $('#map2DSettingInfoContent .up').unbind('click').bind('click', function (e) {
- var _this = $(this).parent();
- $(_this).prev().before(_this)
- })
- $('#map2DSettingInfoContent .down').unbind('click').bind('click', function (e) {
- var _this = $(this).parent();
- $(_this).next().after(_this)
- })
- $('#map2DSettingInfoContent .addsx').unbind('click').bind('click', function (e) {
- var dom = $(this).parent().find(".zixiang").eq(0).clone();
- $(this).parent().append(dom);
- })
- $('#mxList .up').unbind('click').bind('click', function (e) {
- var _this = $(this).parent();
- $(_this).prev().before(_this)
- })
- $('#mxList .down').unbind('click').bind('click', function (e) {
- var _this = $(this).parent();
- $(_this).next().after(_this)
- })
- $('#model3DList .add-new').unbind('click').bind('click', function () {
- addNewMxForm();
- });
- $('#model3DList .add-newb').unbind('click').bind('click', function () {
- seTdModel();
- });
- $('#iGNameList .add-new').unbind('click').bind('click', function () {
- addNewIGForm();
- });
- $('#mxList .delete').unbind('click').bind('click', function (e) {
- if (window.confirm('确定删除?')) {
- var el = e.target ? e.target : e.srcElement;
- $(el).parent().remove();
- $("#map3DSettingInfoContent .model3DModelList").mCustomScrollbar('update');
- }
- });
- $('#iGList .delete').unbind('click').bind('click', function (e) {
- if (window.confirm('确定删除?')) {
- var el = e.target ? e.target : e.srcElement;
- $(el).parent().remove();
- $("#IGoalsSettingInfoContent .iGItemCList").mCustomScrollbar('update');
- }
- });
- $("#dxCList li .delete").unbind('click').bind('click', function () {
- if (window.confirm('确定删除?')) {
- var name = $(this).prev().html();
- removeThematicClumn(name);
- $(this).parent().parent().remove();
- $("#map2DSettingInfoContent .thematicCategoryList").mCustomScrollbar('update');
- }
- })
- $("#dxCList li .editer").unbind('click').bind('click', function () {
- $(this).parent().parent().find('.li_control').hide();
- $(this).parent().parent().find('.li_control_Ch').show();
- });
- $("#dxCList li .cancel").unbind('click').bind('click', function () {
- $(this).parent().parent().find('.li_control').show();
- $(this).parent().parent().find('.li_control_Ch').hide();
- });
- $("#dxCList li .sure").unbind('click').bind('click', function () {
- //数据保存
- var data = {
- newName: $(this).prev().val(),
- oldName: $(this).parent().prev().prev().html(),
- };
- dxCListCaSure(data);
- $(this).parent().parent().find('.li_control').show();
- $(this).parent().parent().find('.li_control_Ch').hide();
- });
- $("#mxCList li .delete").unbind('click').bind('click', function () {
- if (window.confirm('确定删除?')) {
- var name = $(this).prev().html();
- removeModelClumn(name);
- $(this).parent().parent().remove();
- $("#map3DSettingInfoContent .model3DCategoryList").mCustomScrollbar('update');
- }
- })
- $("#mxCList li .editer").unbind('click').bind('click', function () {
- $(this).parent().parent().find('.li_control').hide();
- $(this).parent().parent().find('.li_control_Ch').show();
- });
- $("#mxCList li .cancel").unbind('click').bind('click', function () {
- $(this).parent().parent().find('.li_control').show();
- $(this).parent().parent().find('.li_control_Ch').hide();
- });
- $("#mxCList li .sure").unbind('click').bind('click', function () {
- //数据保存
- var data = {
- newName: $(this).prev().val(),
- oldName: $(this).parent().prev().prev().html(),
- };
- mxCListCaSure(data);
- $(this).parent().parent().find('.li_control').show();
- $(this).parent().parent().find('.li_control_Ch').hide();
- });
- $("#iGCList li .delete").unbind('click').bind('click', function () {
- if (window.confirm('确定删除?')) {
- var name = $(this).prev().html();
- removeIGClumn(name);
- $(this).parent().parent().remove();
- $("#IGoalsSettingInfoContent .iGItemCList").mCustomScrollbar('update');
- }
- })
- $("#iGCList li .editer").unbind('click').bind('click', function () {
- $(this).parent().parent().find('.li_control').hide();
- $(this).parent().parent().find('.li_control_Ch').show();
- });
- $("#iGCList li .cancel").unbind('click').bind('click', function () {
- $(this).parent().parent().find('.li_control').show();
- $(this).parent().parent().find('.li_control_Ch').hide();
- });
- $("#iGCList li .sure").unbind('click').bind('click', function () {
- //数据保存
- var data = {
- newName: $(this).prev().val(),
- oldName: $(this).parent().prev().prev().html(),
- };
- iGCListCaSure(data);
- $(this).parent().parent().find('.li_control').show();
- $(this).parent().parent().find('.li_control_Ch').hide();
- });
- $("#thematicList .listContent li").unbind('click').bind('click', function () {
- var cid = $(this).attr('cid');
- $("#map2DSettingInfoContent .thematicModelList").mCustomScrollbar("scrollTo", "#" + cid + "");
- })
- $("#model3DList .listContent li").unbind('click').bind('click', function () {
- var cid = $(this).attr('cid');
- $("#map3DSettingInfoContent .model3DModelList").mCustomScrollbar("scrollTo", "#" + cid + "");
- })
- $("#iGNameList .listContent li").unbind('click').bind('click', function () {
- var cid = $(this).attr('cid');
- $("#IGoalsSettingInfoContent .iGItemList").mCustomScrollbar("scrollTo", "#" + cid + "");
- })
- $('#thematicList .add-newCa').unbind('click').bind('click', function () {
- addNewCa("thematic");
- })
- $('#model3DList .add-newCa').unbind('click').bind('click', function () {
- addNewCa("threeModel");
- })
- $('#iGNameList .add-newCa').unbind('click').bind('click', function () {
- addNewCa("IG");
- })
- }
- /**
- * 添加新的分类
- */
- function addNewCa(option) {
- var addNewCaHtml = $("<li><span>新分类</span>" +
- "<div class='li_control content'>" +
- "<a class='btn editer btn2 btn-small'>编辑</a>" +
- "<a class='btn delete btn2 btn-small'>删除</a>" +
- "</div>" +
- "<div class='li_control_Ch content'>" +
- "<input class='curCa'>" +
- "<a class='btn sure btn2 btn-small'>确定</a>" +
- "<a class='btn cancel btn2 btn-small'>取消</a>" +
- "</div>" +
- "</li>");
- if (option === "thematic") {
- var length = ONEMAP.D.globalSettingData.map2DThematicCategory.length;
- var content = "新分类" + length;
- addNewCaHtml.find('span').html(content);
- addNewCaHtml.appendTo($("#dxCList"));
- ONEMAP.D.globalSettingData.map2DThematicCategory.push(content);
- } else if (option === "threeModel") {
- var length = ONEMAP.D.globalSettingData.map3DModelSettingCategory.length;
- var content = "新分类" + length;
- addNewCaHtml.find('span').html(content);
- ONEMAP.D.globalSettingData.map3DModelSettingCategory.push(content);
- addNewCaHtml.appendTo($("#mxCList"));
- } else if (option === "IG") {
- var length = ONEMAP.D.globalSettingData.importantGoalsCategory.length;
- var content = "新分类" + length;
- addNewCaHtml.find('span').html(content);
- ONEMAP.D.globalSettingData.importantGoalsCategory.push(content);
- addNewCaHtml.appendTo($("#iGCList"));
- }
- bindEvent();
- }
- /**
- * 二维地图分类修改保存
- */
- function dxCListCaSure(data) {
- //console.log(data);
- var onemapSettingData = ONEMAP.D.globalSettingData.map2DThematicSetting;
- $.each(onemapSettingData, function (i, t) {
- if (t.category === data.oldName) {
- ONEMAP.D.globalSettingData.map2DThematicSetting[i].category = data.newName;
- }
- });
- $.each(ONEMAP.D.globalSettingData.map2DThematicCategory, function (i, t) {
- if (t === data.oldName) {
- ONEMAP.D.globalSettingData.map2DThematicCategory[i] = data.newName;
- }
- });
- reSetLayout();
- };
- /**
- * 三维地图分类修改保存
- */
- function mxCListCaSure(data) {
- //console.log(data);
- var onemapSettingData = ONEMAP.D.globalSettingData.map3DModelSetting;
- $.each(onemapSettingData, function (i, t) {
- if (t.category === data.oldName) {
- ONEMAP.D.globalSettingData.map3DModelSetting[i].category = data.newName;
- }
- });
- $.each(ONEMAP.D.globalSettingData.map3DModelSettingCategory, function (i, t) {
- if (t === data.oldName) {
- ONEMAP.D.globalSettingData.map3DModelSettingCategory[i] = data.newName;
- }
- });
- reSetLayout();
- };
- /**
- * 重要目标与事件分类修改保存
- */
- function iGCListCaSure(data) {
- //console.log(data);
- var onemapSettingData = ONEMAP.D.globalSettingData.importantGoalsSetting;
- $.each(onemapSettingData, function (i, t) {
- if (t.category === data.oldName) {
- ONEMAP.D.globalSettingData.importantGoalsSetting[i].category = data.newName;
- }
- });
- $.each(ONEMAP.D.globalSettingData.importantGoalsCategory, function (i, t) {
- if (t === data.oldName) {
- ONEMAP.D.globalSettingData.importantGoalsCategory[i] = data.newName;
- }
- });
- reSetLayout();
- };
- /**
- * 根据分类移除重要目标与事件
- */
- function removeIGClumn(options) {
- $('#iGList .item-form').each(function (index, item) {
- var clumnName = $(item).find('input[name="category"]').val();
- if (clumnName === options) {
- $(item).remove();
- var name = $(item).find('input[name="name"]').val();
- $("#iGNameList .listContent").find('li[tab="' + name + '"]').remove();
- }
- });
- $("#iGNameList ul").mCustomScrollbar("update");
- $("#IGoalsSettingInfoContent .iGItemList").mCustomScrollbar("update");
- }
- /**
- * 根据分类移除三维模型
- */
- function removeModelClumn(options) {
- $('#mxList .item-form').each(function (index, item) {
- var clumnName = $(item).find('input[name="category"]').val();
- if (clumnName === options) {
- $(item).remove();
- var name = $(item).find('input[name="name"]').val();
- $("#model3DList .listContent").find('li[tab="' + name + '"]').remove();
- }
- });
- $("#model3DList ul").mCustomScrollbar("update");
- $("#map3DSettingInfoContent .model3DModelList").mCustomScrollbar("update");
- };
- /**
- * 根据分类移除专题图层
- */
- function removeThematicClumn(options) {
- $('#dxList .item-form').each(function (index, item) {
- var clumnName = $(item).find('input[name="category"]').val();
- if (clumnName === options) {
- $(item).remove();
- var name = $(item).find('input[name="name"]').val();
- $("#thematicList .listContent").find('li[tab="' + name + '"]').remove();
- }
- });
- $("#thematicList ul").mCustomScrollbar("update");
- $('#map2DSettingInfoContent .thematicModelList').mCustomScrollbar("update");
- };
- /**
- * 构建重要目标与事件列表
- * @type {Function}
- * @private
- */
- function buildIGList() {
- $('#IGoalsSettingInfoContent #iGList').empty();
- $("#iGNameList ul").empty();
- $.each(ONEMAP.D.globalSettingData.importantGoalsSetting, function (i, item) {
- var id = map23DControl.buildGuid();
- item.id = id;
- var iGListTemplate = Handlebars.compile($('#IG-item-template').html());
- $('#IGoalsSettingInfoContent #iGList').append(iGListTemplate(item));
- $("<li tab='" + item.name + "' cId='" + id + "'>" + item.name + "</li>").appendTo($("#iGNameList ul"));
- });
- var chooseHtml = $('<ul class="chhoostListContent"></ul>');
- for (var i = 0; i < ONEMAP.D.globalSettingData.importantGoalsCategory.length; i++) {
- var liHtml = $('<li>' + ONEMAP.D.globalSettingData.importantGoalsCategory[i] + '</li>');
- $(liHtml).appendTo($(chooseHtml));
- }
- $("#iGList .category .chhoostListContent").remove();
- $(chooseHtml).appendTo($("#iGList .category").parent());
- //分类输入框选择
- $("#iGList .category").unbind('focus').bind('focus', function (e) {
- e.stopPropagation();
- $(this).next().show();
- $(this).parent().parent().parent().siblings().find('.chhoostListContent').hide();
- });
- $("#iGList .chhoostListContent li").unbind('click').bind('click', function () {
- $("#iGList .chhoostListContent").hide();
- $(this).parent().parent().find('input').val($(this).html());
- });
- }
- /**
- * 构建地形图数据列表
- * @type {Function}
- * @private
- */
- function buildDxForm() {
- $("#thematicList ul").empty();
- $('#map2DSettingInfoContent #dxList').empty();
- if (ONEMAP.D.globalSettingData.baseMap2D) {
- $('#mapLat').val(ONEMAP.D.globalSettingData.baseMap2D.center.lat);
- $('#mapLng').val(ONEMAP.D.globalSettingData.baseMap2D.center.lng);
- $('#mapZoom').val(ONEMAP.D.globalSettingData.baseMap2D.zoom);
- $('#mapType').val(ONEMAP.D.globalSettingData.baseMap2D.type);
- }
- $.each(ONEMAP.D.globalSettingData.map2DThematicSetting, function (i, item) {
- var id = map23DControl.buildGuid();
- item.id = id;
- if (item.type === "thematicOrigin") {
- var dxListTemplate = Handlebars.compile($('#dixing-item-templateTOrigin').html());
- $('#map2DSettingInfoContent #dxList').append(dxListTemplate(item));
- } else if (item.type === "vectorOrigin") {
- var dxListTemplate = Handlebars.compile($('#dixing-item-templateVOrigin').html());
- $('#map2DSettingInfoContent #dxList').append(dxListTemplate(item));
- } else if (item.type === "weatherMap") {
- var dxListTemplate = Handlebars.compile($('#dixing-item-templateWOrigin').html());
- $('#map2DSettingInfoContent #dxList').append(dxListTemplate(item));
- } else if (item.type === "otherOrigin") {
- var dxListTemplate = Handlebars.compile($('#dixing-item-templateOOrigin').html());
- $('#map2DSettingInfoContent #dxList').append(dxListTemplate(item));
- } else if (item.type === "shixuOrigin") {
- var dxListTemplate = Handlebars.compile($('#dixing-item-templateSOrigin').html());
- $('#map2DSettingInfoContent #dxList').append(dxListTemplate(item));
- }
- $("<li tab='" + item.name + "' cId='" + id + "'>" + item.name + "</li>").appendTo($("#thematicList ul"));
- });
- var chooseHtml = $('<ul class="chhoostListContent"></ul>');
- for (var i = 0; i < ONEMAP.D.globalSettingData.map2DThematicCategory.length; i++) {
- var liHtml = $('<li>' + ONEMAP.D.globalSettingData.map2DThematicCategory[i] + '</li>');
- $(liHtml).appendTo($(chooseHtml));
- }
- $("#dxList .category .chhoostListContent").remove();
- $(chooseHtml).appendTo($("#dxList .category").parent());
- //分类输入框选择
- $("#dxList .category").unbind('focus').bind('focus', function (e) {
- $(this).next().show();
- $(this).parent().parent().parent().siblings().find('.chhoostListContent').hide();
- e.stopPropagation();
- });
- $("#dxList .chhoostListContent li").unbind('click').bind('click', function () {
- $("#dxList .chhoostListContent").hide();
- $(this).parent().parent().find('input').val($(this).html());
- });
- };
- /**
- * 添加一条新的地形图表单
- * @type {Function}
- * @private
- */
- function addNewDxForm(options) {
- if (options === "thematicOrigin") {
- $('#map2DSettingInfoContent #dxList').append($('#dixing-item-formTOrigin-template').html())
- } else if (options === "vectorOrigin") {
- $('#map2DSettingInfoContent #dxList').append($('#dixing-item-formVOrigin-template').html())
- } else if (options === "weatherMap") {
- $('#map2DSettingInfoContent #dxList').append($('#dixing-item-formWeather-template').html())
- } else if (options === "otherOrigin") {
- $('#map2DSettingInfoContent #dxList').append($('#dixing-item-formOOrigin-template').html())
- } else if (options === "shixuOrigin") {
- $('#map2DSettingInfoContent #dxList').append($('#dixing-item-formSOrigin-template').html())
- }
- var chooseHtml = $('<ul class="chhoostListContent"></ul>');
- for (var i = 0; i < ONEMAP.D.globalSettingData.map2DThematicCategory.length; i++) {
- var liHtml = $('<li>' + ONEMAP.D.globalSettingData.map2DThematicCategory[i] + '</li>');
- $(liHtml).appendTo($(chooseHtml));
- }
- $("#dxList .category .chhoostListContent").remove();
- $(chooseHtml).appendTo($("#dxList .category").parent());
- //分类输入框选择
- $("#dxList .category").unbind('focus').bind('focus', function (e) {
- e.stopPropagation();
- $(this).next().show();
- $(this).parent().parent().parent().siblings().find('.chhoostListContent').hide();
- });
- $("#dxList .chhoostListContent li").unbind('click').bind('click', function () {
- $("#dxList .chhoostListContent").hide();
- $(this).parent().parent().find('input').val($(this).html());
- });
- $('#map2DSettingInfoContent .thematicModelList').mCustomScrollbar("update");
- $('#map2DSettingInfoContent .thematicModelList').mCustomScrollbar("scrollTo", "bottom");
- bindEvent();
- };
- /**
- * 构建模型数据列表
- * @type {Function}
- * @private
- */
- function buildMxForm() {
- // console.log("build");
- $('#mxList').empty();
- $("#model3DList ul").empty();
- if (ONEMAP.D.globalSettingData.baseMap3D) {
- //$('#base3DMapUrl').val(ONEMAP.D.globalSettingData.baseMap3D.map3DLayer);
- $('#base3DMapDEM').val(ONEMAP.D.globalSettingData.baseMap3D.map3DDEM);
- $('#base3DMapName').val(ONEMAP.D.globalSettingData.baseMap3D.map3DName);
- }
- $.each(ONEMAP.D.globalSettingData.map3DModelSetting, function (i, item) {
- var id = map23DControl.buildGuid();
- item.id = id;
- if (item.type === "mxData") {
- var mxListTemplate = Handlebars.compile($('#moxing-item-templatemx').html());
- $('#mxList').append(mxListTemplate(item));
- } else {
- var mxListTemplate = Handlebars.compile($('#moxing-item-templateqx').html());
- $('#mxList').append(mxListTemplate(item));
- }
- $("<li tab='" + item.name + "' cId='" + id + "'>" + item.name + "</li>").appendTo($("#model3DList ul"));
- })
- var chooseHtml = $('<ul class="chhoostListContent"></ul>');
- for (var i = 0; i < ONEMAP.D.globalSettingData.map3DModelSettingCategory.length; i++) {
- var liHtml = $('<li>' + ONEMAP.D.globalSettingData.map3DModelSettingCategory[i] + '</li>');
- $(liHtml).appendTo($(chooseHtml));
- }
- $("#mxList .category .chhoostListContent").remove();
- $(chooseHtml).appendTo($("#mxList .category").parent());
- //分类输入框选择
- $("#mxList .category").unbind('focus').bind('focus', function (e) {
- e.stopPropagation();
- $(this).next().show();
- });
- $("#mxList .chhoostListContent li").unbind('click').bind('click', function () {
- $("#mxList .chhoostListContent").hide();
- $(this).parent().parent().find('input').val($(this).html());
- });
- };
- /**
- * 添加新的重要目标与事件菜单
- */
- function addNewIGForm() {
- $('#iGList').append($('#IG-item-form-template').html());
- var chooseHtml = $('<ul class="chhoostListContent"></ul>');
- for (var i = 0; i < ONEMAP.D.globalSettingData.importantGoalsCategory.length; i++) {
- var liHtml = $('<li>' + ONEMAP.D.globalSettingData.importantGoalsCategory[i] + '</li>');
- $(liHtml).appendTo($(chooseHtml));
- }
- $("#iGList .category .chhoostListContent").remove();
- $(chooseHtml).appendTo($("#iGList .category").parent());
- //分类输入框选择
- $("#iGList .category").unbind('focus').bind('focus', function (e) {
- e.stopPropagation();
- $(this).next().show();
- });
- $("#iGList .chhoostListContent li").unbind('click').bind('click', function () {
- $("#iGList .chhoostListContent").hide();
- $(this).parent().parent().find('input').val($(this).html());
- });
- $("#IGoalsSettingInfoContent .iGItemList").mCustomScrollbar("update");
- $("#IGoalsSettingInfoContent .iGItemList").mCustomScrollbar("scrollTo", "bottom");
- bindEvent();
- };
- /**
- * 添加一条新的模型表单
- * @type {Function}
- * @private
- */
- function seTdModel() {
- var tdSet = {},
- tdSetQ = {};
- $("#tdtsList ul").html("");
- $.ajax({
- url: onemapUrlConfig.tdModelUrl,
- type: 'GET',
- dataType: 'json'
- })
- .done(function (data) {
- console.log(data)
- if (onemapUrlConfig.threeDimensionalDataUrl.indexOf("v1.0") > -1) {
- tdSet = data;
- } else {
- tdSet = data.data;
- }
- for (var i = 0; i < tdSet.length; i++) {
- var tdata = JSON.stringify(tdSet[i]).replace(/\"/g, "\'");
- var pli = $('<li dt="' + tdata + '" type="1"><span class="check"></span><span class="name">' + tdSet[i].layer_name + '</span></li>');
- $("#tdtsList .p1 ul").prepend(pli);
- }
- $("#tdtsList li .check").off("click").on("click", function () {
- if ($(this).parent().hasClass('checked')) {
- $(this).parent().removeClass('checked')
- $(this).removeClass('bg')
- } else {
- $(this).parent().addClass('checked');
- $(this).addClass('bg');
- }
- })
- })
- $.ajax({
- url: onemapUrlConfig.tdQxsyUrl,
- type: 'GET',
- dataType: 'json'
- })
- .done(function (data) {
- console.log(data)
- if (onemapUrlConfig.threeDimensionalDataUrl.indexOf("v1.0") > -1) {
- tdSetQ = data;
- } else {
- tdSetQ = data.data;
- }
- for (var i = 0; i < tdSetQ.length; i++) {
- var tdata = JSON.stringify(tdSetQ[i]).replace(/\"/g, "\'");
- var pli = $('<li dt="' + tdata + '" type="2"><span class="check"></span><span class="name">' + tdSetQ[i].layer_name + '</span></li>');
- $("#tdtsList .p2 ul").prepend(pli);
- }
- $("#tdtsList li .check").off("click").on("click", function () {
- if ($(this).parent().hasClass('checked')) {
- $(this).parent().removeClass('checked')
- $(this).removeClass('bg')
- } else {
- $(this).parent().addClass('checked');
- $(this).addClass('bg');
- }
- })
- })
- // $("#tdTheSelect").addClass('active');
- $(".bacover").show();
- // $("#tdTheSelect .submit").off("click").on("click",function(){
- // var value = $("#tdMChoose").val();
- // if(value == 1){
- // $('#mxList').append($('#moxing-item-form-template').html());
- // addNewMxForm()
- // } else if(value == 2){
- $("#tdtsList").addClass('active')
- $("#tdtsList ul").mCustomScrollbar({
- scrollInertia: 100
- });
- // }
- // $("#tdTheSelect").removeClass('active');
- // })
- // $("#tdTheSelect .cancel").off("click").on("click",function(){
- // $("#tdTheSelect").removeClass('active');
- // $(".bacover").hide();
- // })
- $("#tdtsList .cancel").off("click").on("click", function () {
- $("#tdtsList").removeClass('active');
- $(".bacover").hide();
- })
- $("#tdtsList .submit").off("click").on("click", function () {
- var lis = $("#tdtsList li.checked");
- for (var i = 0; i < lis.length; i++) {
- var dt = lis.eq(i).attr("dt").replace(/\'/g, "\"");
- var ldata = JSON.parse(dt);
- var type = lis.eq(i).attr("type");
- var category, st;
- if (type == 1) {
- category = "三维模型", st = 0;
- if (onemapUrlConfig.threeDimensionalDataUrl.indexOf("v1.0") > -1) {
- $("#tdyuanModel .item-form .modelUrl").attr("value", onemapUrlConfig.threeDimensionalDataUrl + '/geo_model/' + ldata.guid + '.gfp');
- } else {
- $("#tdyuanModel .item-form .modelUrl").attr("value", onemapUrlConfig.threeDimensionalDataUrl + '/geo_model/' + ldata.guid + '/subfile/' + ldata.guid + '.json');
- }
- } else if (type == 2) {
- category = "倾斜摄影", st = 1;
- if (onemapUrlConfig.threeDimensionalDataUrl.indexOf("v1.0") > -1) {
- $("#tdyuanModel .item-form .modelUrl").attr("value", onemapUrlConfig.threeDimensionalDataUrl + '/oblique/global/' + ldata.guid + '.gft');
- } else {
- $("#tdyuanModel .item-form .modelUrl").attr("value", onemapUrlConfig.threeDimensionalDataUrl + '/oblique/' + ldata.guid + '/subfile/' + ldata.guid + '.json');
- }
- }
- $("#tdyuanModel .item-form .name").attr("value", ldata.layer_name);
- $("#tdyuanModel .item-form .center-lat").attr("value", ldata.center[1]);
- $("#tdyuanModel .item-form .center-lng").attr("value", ldata.center[0]);
- $("#tdyuanModel .item-form .guid").attr("value", ldata.guid);
- $("#tdyuanModel .item-form .category").attr("value", category);
- $("#tdyuanModel .item-form .zoom").attr("value", 1000);
- $("#tdyuanModel .item-form select option").eq(st).attr("selected", true)
- $('#mxList').append($('#tdyuanModel').html());
- }
- $("#tdtsList").removeClass('active');
- $(".bacover").hide();
- bindEvent()
- $("#map3DSettingInfoContent .model3DModelList").mCustomScrollbar("update");
- $("#map3DSettingInfoContent .model3DModelList").mCustomScrollbar("scrollTo", "bottom");
- })
- $("#tdtsList .title span").off("click").on("click", function () {
- if ($(this).hasClass('he')) {
- $(this).removeClass('he')
- $(this).parents().filter(".mtype").find("ul").removeClass('he')
- } else {
- $(this).addClass('he')
- $(this).parents().filter(".mtype").find("ul").addClass('he')
- }
- })
- }
- function addNewMxForm() {
- $('#mxList').append($('#moxing-item-form-template').html());
- var chooseHtml = $('<ul class="chhoostListContent"></ul>');
- for (var i = 0; i < ONEMAP.D.globalSettingData.map3DModelSettingCategory.length; i++) {
- var liHtml = $('<li>' + ONEMAP.D.globalSettingData.map3DModelSettingCategory[i] + '</li>');
- $(liHtml).appendTo($(chooseHtml));
- }
- $("#mxList .category .chhoostListContent").remove();
- $(chooseHtml).appendTo($("#mxList .category").parent());
- //分类输入框选择
- $("#mxList .category").unbind('focus').bind('focus', function (e) {
- e.stopPropagation();
- $(this).next().show();
- });
- $("#mxList .chhoostListContent li").unbind('click').bind('click', function () {
- $("#mxList .chhoostListContent").hide();
- $(this).parent().parent().find('input').val($(this).html());
- });
- $("#map3DSettingInfoContent .model3DModelList").mCustomScrollbar("update");
- $("#map3DSettingInfoContent .model3DModelList").mCustomScrollbar("scrollTo", "bottom");
- bindEvent();
- };
- /**
- * 构建重要目标与事件分类数据
- */
- function buildIGCa() {
- $("#iGCList").empty();
- if (ONEMAP.D.globalSettingData.importantGoalsCategory) {
- var data = ONEMAP.D.globalSettingData.importantGoalsCategory;
- for (var i = 0; i < data.length; i++) {
- $("<li><span>" + data[i] + "</span>" +
- "<div class='li_control content'>" +
- "<a class='btn editer btn2 btn-small'>编辑</a>" +
- "<a class='btn delete btn2 btn-small'>删除</a>" +
- "</div>" +
- "<div class='li_control_Ch content'>" +
- "<input class='curCa'>" +
- "<a class='btn sure btn2 btn-small'>确定</a>" +
- "<a class='btn cancel btn2 btn-small'>取消</a>" +
- "</div>" +
- "</li>").appendTo($("#iGCList"))
- }
- }
- }
- /**
- * 构建专题图分类数据
- */
- function buildThemativC() {
- $("#dxCList").empty();
- if (ONEMAP.D.globalSettingData.map2DThematicCategory) {
- var data = ONEMAP.D.globalSettingData.map2DThematicCategory;
- for (var i = 0; i < data.length; i++) {
- $("<li><span>" + data[i] + "</span>" +
- "<div class='li_control content'>" +
- "<a class='btn editer btn2 btn-small'>编辑</a>" +
- "<a class='btn delete btn2 btn-small'>删除</a>" +
- "</div>" +
- "<div class='li_control_Ch content'>" +
- "<input class='curCa'>" +
- "<a class='btn sure btn2 btn-small'>确定</a>" +
- "<a class='btn cancel btn2 btn-small'>取消</a>" +
- "</div>" +
- "</li>").appendTo($("#dxCList"))
- }
- }
- }
- /**
- * 构建三维模型分类数据
- */
- function buildModelC() {
- $("#mxCList").empty();
- if (ONEMAP.D.globalSettingData.map3DModelSettingCategory) {
- var data = ONEMAP.D.globalSettingData.map3DModelSettingCategory;
- for (var i = 0; i < data.length; i++) {
- $("<li><span>" + data[i] + "</span>" +
- "<div class='li_control content'>" +
- "<a class='btn editer btn2 btn-small'>编辑</a>" +
- "<a class='btn delete btn2 btn-small'>删除</a>" +
- "</div>" +
- "<div class='li_control_Ch content'>" +
- "<input class='curCa'>" +
- "<a class='btn sure btn2 btn-small'>确定</a>" +
- "<a class='btn cancel btn2 btn-small'>取消</a>" +
- "</div>" +
- "</li>").appendTo($("#mxCList"))
- }
- }
- }
- /**
- * 外部添加重点方向与目标
- */
- function linkAddIG(options) {
- if (!modValue.initialized) {
- init();
- };
- var contentId = "IGoalsSetting";
- $(".left_header").find('li[tab="IGoalsSetting"]').addClass('active');
- $(".left_header").find('li[tab="IGoalsSetting"]').siblings().removeClass('active');
- $("#" + contentId).show();
- $("#" + contentId).siblings().hide();
- $("#" + contentId + "InfoContent").show();
- $("#" + contentId + "InfoContent").siblings().hide();
- var iGListTemplate = Handlebars.compile($('#IG-item-template').html());
- // $('#IGoalsSettingInfoContent #iGList').append(iGListTemplate(options));
- var chooseHtml = $('<ul class="chhoostListContent"></ul>');
- for (var i = 0; i < ONEMAP.D.globalSettingData.importantGoalsCategory.length; i++) {
- var liHtml = $('<li>' + ONEMAP.D.globalSettingData.importantGoalsCategory[i] + '</li>');
- $(liHtml).appendTo($(chooseHtml));
- }
- $("#iGList .category .chhoostListContent").remove();
- $(chooseHtml).appendTo($("#iGList .category").parent());
- //分类输入框选择
- $("#iGList .category").unbind('focus').bind('focus', function (e) {
- e.stopPropagation();
- $(this).next().show();
- });
- $("#iGList .chhoostListContent li").unbind('click').bind('click', function () {
- $("#iGList .chhoostListContent").hide();
- $(this).parent().parent().find('input').val($(this).html());
- });
- };
- /**
- * 获取地形图表单数据
- * @type {Function}
- * @returns {Array} 地形图数据数组
- * @private
- */
- function getDxFormData() {
- var map2DThematicSetting = [];
- if ($('#dxList .item-form').length > 0) {
- $('#dxList .item-form').each(function (index, item) {
- var tempObj = {};
- var guid = "";
- var productUrl = "";
- var category = $(item).find('input[name="category"]').val();
- var type = $(item).find('input[name="type"]').val();
- var legend = $(item).find('input[name="legend"]').val();
- var info = $(item).find('input[name="info"]').val();
- var name = $(item).find('input[name="name"]').val();
- var zoom = $(item).find('input[name="zoom"]').val();
- var centerLat = $(item).find('input[name="center-lat"]').val();
- var centerLng = $(item).find('input[name="center-lng"]').val();
- var tileLayerUrl = $(item).find('input[name="tileLayerUrl"]').val();
- if (type === "专题图图源") {
- type = "thematicOrigin";
- } else if (type === "矢量图源") {
- type = "vectorOrigin";
- } else if (type === "第三方图源") {
- type = "otherOrigin";
- } else if (type === "气象云图") {
- type = "weatherMap";
- } else if (type === "时序图层图源") {
- type = "shixuOrigin";
- category = "时序图层";
- }
- if (type == "shixuOrigin") {
- var intervalTime = $(item).find('input[name="intervalTime"]').val();
- var time = $(item).find('input[name="time"]').val();
- var inputs = $(item).find("input");
- for (var i = 0; i < inputs.length; i++) {
- if (inputs[i].value.length < 1) {
- alert("时序图层的所有项不得为空");
- }
- }
- if (name.length > 16 || name.length < 1) {
- alert('名称为 ' + name + ' 的文字长度为1-16个字符');
- status.canPost = false;
- return false;
- }
- if (time.length = 0) {
- alert('时间不能为空');
- status.canPost = false;
- return false;
- }
- if (tileLayerUrl.length = 0) {
- alert('url地址不能为空');
- status.canPost = false;
- return false;
- }
- if (centerLat < -90 || centerLat > 90 || centerLng < -180 || centerLng > 180) {
- alert('名称为 ' + name + ' 的中心点超出经纬度范围');
- status.canPost = false;
- return false;
- }
- tempObj.type = type;
- tempObj.info = info;
- tempObj.name = name;
- tempObj.category = category;
- tempObj.intervalTime = intervalTime;
- tempObj.zoom = parseInt(zoom);
- tempObj.center = {
- lat: parseFloat(centerLat),
- lng: parseFloat(centerLng)
- };
- tempObj.zixiang = [];
- var zixiang = $(item).find(".zixiang");
- for (var i = 0; i < zixiang.length; i++) {
- var zx = {};
- zx.sxTime = zixiang.eq(i).find('input[name="time"]').val();
- zx.sxUrl = zixiang.eq(i).find('input[name="tileLayerUrl"]').val();
- tempObj.zixiang.push(zx);
- }
- map2DThematicSetting.push(tempObj);
- status.canPost = true;
- } else if (category.length > 0 && type.length > 0 && name.length > 0 && zoom.length > 0 && centerLat.length > 0 && centerLng.length > 0 && tileLayerUrl.length > 0) {
- if (name.length > 16) {
- alert('名称为 ' + name + ' 的文字长度不能超过16个字符');
- status.canPost = false;
- return false;
- }
- if (centerLat < -90 || centerLat > 90 || centerLng < -180 || centerLng > 180) {
- alert('名称为 ' + name + ' 的中心点超出经纬度范围');
- status.canPost = false;
- return false;
- }
- if (type === "thematicOrigin") {
- guid = $(item).find('input[name="guid"]').val();
- if (guid.length = 0) {
- alert('名称为 ' + name + '的guid不能为空');
- status.canPost = false;
- return false;
- }
- }
- if (type === "weatherMap") {
- productUrl = $(item).find('input[name="productUrl"]').val();
- guid = $(item).find('input[name="guid"]').val();
- if (productUrl.length = 0) {
- alert('名称为 ' + name + '的产品服务地址不能为空');
- status.canPost = false;
- return false;
- }
- if (guid.length = 0) {
- alert('名称为 ' + name + '的guid不能为空');
- status.canPost = false;
- return false;
- }
- }
- tempObj.category = category;
- tempObj.type = type;
- tempObj.legend = legend;
- tempObj.info = info;
- tempObj.name = name;
- if (guid.length > 0) {
- tempObj.guid = guid;
- }
- if (productUrl.length > 0) {
- tempObj.productUrl = productUrl;
- }
- tempObj.zoom = parseInt(zoom);
- tempObj.center = {
- lat: parseFloat(centerLat),
- lng: parseFloat(centerLng)
- };
- tempObj.url = tileLayerUrl;
- map2DThematicSetting.push(tempObj);
- status.canPost = true;
- } else {
- alert('名称为 ' + name + ' 的所有选项都是必填选项!请填写完整');
- status.canPost = false;
- return false;
- }
- });
- } else {
- status.canPost = true;
- }
- return map2DThematicSetting;
- };
- /**
- * 获取模型表单数据
- * @type {Function}
- * @returns {Array} 模型数据数组
- * @private
- */
- function getMxFormData() {
- var map3DModelSetting = [];
- if ($('#mxList .item-form').length > 0) {
- $('#mxList .item-form').each(function (index, item) {
- var tempObj = {};
- var category = $(item).find('input[name="category"]').val();
- var type = $(item).find('select[name="type"]').val();
- var name = $(item).find('input[name="name"]').val();
- var info = $(item).find('input[name="info"]').val();
- // var height = $(item).find('input[name="height"]').val();
- var centerLat = $(item).find('input[name="center-lat"]').val();
- var centerLng = $(item).find('input[name="center-lng"]').val();
- var modelUrl = $(item).find('input[name="modelUrl"]').val();
- if (type.length > 0 && category.length > 0 && name.length > 0 && centerLat.length > 0 && centerLng.length > 0 && modelUrl.length > 0) { //&& height.length > 0
- if (name.length > 16) {
- alert('名称为 ' + name + ' 的文字长度不能超过16个字符');
- status.canPost = false;
- return false;
- }
- if (centerLat < -90 || centerLat > 90 || centerLng < -180 || centerLng > 180) {
- alert('名称为 ' + name + ' 的中心点超出经纬度范围');
- status.canPost = false;
- return false;
- }
- if(type == "mxData"){
- tempObj.m_height = $(item).find('input[name="m_height"]').val();
- tempObj.m_scale = $(item).find('input[name="m_scale"]').val();
- tempObj.m_hdeading = $(item).find('input[name="m_hdeading"]').val();
- tempObj.m_pitch = $(item).find('input[name="m_pitch"]').val();
- tempObj.m_roll = $(item).find('input[name="m_roll"]').val();
- }
- tempObj.category = category;
- tempObj.info = info;
- tempObj.type = type;
- tempObj.name = name;
- // tempObj.zoom = parseInt(height);
- tempObj.center = {
- lat: parseFloat(centerLat),
- lng: parseFloat(centerLng)
- };
- tempObj.url = modelUrl;
- map3DModelSetting.push(tempObj);
- status.canPost = true;
- } else {
- alert('名称为 ' + name + ' 的所有选项都是必填选项!请填写完整');
- status.canPost = false;
- return false;
- }
- });
- } else {
- status.canPost = true;
- }
- return map3DModelSetting;
- };
- /**
- * 获取二维地图设置数据
- */
- function getMap2DFromData() {
- var baseMap2D = {};
- var mapLat = ($('#map2DForm').find('input[name="mapLat"]').val()).replace(/\ /g, "");
- var mapLng = ($('#map2DForm').find('input[name="mapLng"]')).val().replace(/\ /g, "");
- var mapZoom = parseInt($('#mapZoom').val());
- var mapType = $('#mapType').val();
- if (mapLat.length > 0 && mapLng.length > 0) {
- if (mapLat < -90 && mapLat > 90 && mapLng < -180 && mapLng > 180) {
- alert('地图默认中心点超出经纬度范围');
- status.canPost = false;
- return false;
- }
- baseMap2D.center = {
- lat: parseFloat(mapLat),
- lng: parseFloat(mapLng)
- };
- baseMap2D.type = parseInt(mapType);
- baseMap2D.zoom = parseInt(mapZoom);
- status.canPost = true;
- } else {
- alert('二维地图设置所有选项都是必填选项!请填写完整');
- status.canPost = false;
- return false;
- }
- return baseMap2D;
- }
- /**
- * 获取三维地图设置
- */
- function getMap3DFromData() {
- var baseMap3D = {};
- //var baseMap3D_Layer = $('#map3DForm').find('input[name="base3DMapUrl"]').val();
- var baseMap3D_DEM = $('#map3DForm').find('input[name="base3DMapDEM"]').val();
- var baseMap3D_Name = $('#map3DForm').find('input[name="base3DMapName"]').val();
- if (baseMap3D_DEM.length > 0 && baseMap3D_Name.length > 0) {
- //baseMap3D.map3DLayer = baseMap3D_Layer;
- baseMap3D.map3DDEM = baseMap3D_DEM;
- baseMap3D.map3DName = baseMap3D_Name;
- status.canPost = true;
- } else {
- alert('三维地图设置所有选项都是必填选项!请填写完整');
- status.canPost = false;
- return false;
- }
- return baseMap3D;
- };
- /**
- * 获取专题地图数据栏目
- */
- function getThematicCategory() {
- var map2DThematicCategory = [];
- if ($('#dxList .item-form').length > 0) {
- $('#dxList .item-form').each(function (index, item) {
- var isAddToArray = false;
- var category = $(item).find('input[name="category"]').val();
- var type = $(item).find('input[name="type"]').val();
- if (type == "时序图层图源") {
- category = "时序图层"
- }
- for (var i = 0; i < map2DThematicCategory.length; i++) {
- if (map2DThematicCategory[i] === category) {
- isAddToArray = true;
- }
- }
- if (!isAddToArray) {
- map2DThematicCategory.push(category);
- }
- })
- }
- $("#dxCList li").each(function (index, item) {
- var isAddToArray = false;
- var category = $(item).find('span').html();
- for (var i = 0; i < map2DThematicCategory.length; i++) {
- if (map2DThematicCategory[i] === category) {
- isAddToArray = true;
- }
- }
- if (!isAddToArray) {
- map2DThematicCategory.push(category);
- }
- })
- return map2DThematicCategory;
- };
- /**
- * 获取三维模型分类
- */
- function getModel3DCategory() {
- var map3DModelSettingCategory = [];
- if ($('#mxList .item-form').length > 0) {
- $('#mxList .item-form').each(function (index, item) {
- var category = $(item).find('input[name="category"]').val();
- var isAddToArray = false;
- for (var i = 0; i < map3DModelSettingCategory.length; i++) {
- if (map3DModelSettingCategory[i] === category) {
- isAddToArray = true;
- }
- }
- if (!isAddToArray) {
- map3DModelSettingCategory.push(category);
- }
- })
- }
- $("#mxCList li").each(function (index, item) {
- var isAddToArray = false;
- var category = $(item).find('span').html();
- for (var i = 0; i < map3DModelSettingCategory.length; i++) {
- if (map3DModelSettingCategory[i] === category) {
- isAddToArray = true;
- }
- }
- if (!isAddToArray) {
- map3DModelSettingCategory.push(category);
- }
- })
- return map3DModelSettingCategory;
- }
- /**
- * 获取重点目标分类
- */
- function getImportantGC() {
- var importantGoalsCategory = [];
- if ($('#iGList .item-form').length > 0) {
- $('#iGList .item-form').each(function (index, item) {
- var isAddToArray = false;
- var category = $(item).find('input[name="category"]').val();
- for (var i = 0; i < importantGoalsCategory.length; i++) {
- if (importantGoalsCategory[i] === category) {
- isAddToArray = true;
- }
- }
- if (!isAddToArray) {
- importantGoalsCategory.push(category);
- }
- })
- }
- $("#iGCList li").each(function (index, item) {
- var isAddToArray = false;
- var category = $(item).find('span').html();
- for (var i = 0; i < importantGoalsCategory.length; i++) {
- if (importantGoalsCategory[i] === category) {
- isAddToArray = true;
- }
- }
- if (!isAddToArray) {
- importantGoalsCategory.push(category);
- }
- })
- return importantGoalsCategory;
- }
- function getImportantData() {
- var importantGoalsSetting = [];
- if ($('#iGList .item-form').length > 0) {
- $('#iGList .item-form').each(function (index, item) {
- var tempObj = {};
- var category = $(item).find('input[name="category"]').val();
- var columnName = $(item).find('input[name="columnName"]').val();
- var name = $(item).find('input[name="name"]').val();
- if (category.length > 0 && name.length > 0 && columnName.length > 0) {
- if (name.length > 16) {
- alert('名称为 ' + name + ' 的文字长度不能超过16个字符');
- status.canPost = false;
- return false;
- }
- tempObj.category = category;
- tempObj.name = name;
- tempObj.columnName = columnName;
- importantGoalsSetting.push(tempObj);
- status.canPost = true;
- } else {
- alert('名称为 ' + name + ' 的所有选项都是必填选项!请填写完整');
- status.canPost = false;
- return false;
- }
- });
- } else {
- status.canPost = true;
- }
- return importantGoalsSetting;
- };
- function getKuozhanData() {
- var kuozhanData = [];
- if ($("#kzList li").length > 0) {
- $("#kzList li").each(function (index, item) {
- var tempObj = {};
- var title = $(item).find('input[name="title"]').val();
- var link = $(item).find('input.linkAddr').val();
- if (title.length > 0 && link.length > 0) {
- if (title.length > 16) {
- alert('名称为 ' + title + ' 的文字长度不能超过16个字符');
- status.canPost = false;
- return false;
- }
- tempObj.title = title;
- tempObj.link = link;
- kuozhanData.push(tempObj);
- status.canPost = true;
- } else {
- alert('名称为 ' + title + ' 的所有选项都是必填选项!请填写完整');
- status.canPost = false;
- return false;
- }
- })
- } else {
- status.canPost = true;
- }
- console.log(kuozhanData);
- return kuozhanData;
- }
- /**
- * 获取地图模式设置单数据
- * @type {Function}
- * @returns {Array}
- * @private
- */
- function getMapFormData() {
- var mapData = {};
- var mapLat = ($('#map2DForm').find('input[name="mapLat"]').val()).replace(/\ /g, "");
- var mapLng = ($('#map2DForm').find('input[name="mapLng"]')).val().replace(/\ /g, "");
- var mapZoom = parseInt($('#mapZoom').val());
- var mapType = $('#mapType').val();
- if (mapLat.length > 0 && mapLng.length > 0) {
- if (mapLat < -90 || mapLat > 90 || mapLng < -180 || mapLng > 180) {
- alert('地图默认中心点超出经纬度范围');
- status.canPost = false;
- return false;
- }
- mapData.center = {
- lat: parseFloat(mapLat),
- lng: parseFloat(mapLng)
- };
- mapData.type = parseInt(mapType);
- mapData.zoom = parseInt(mapZoom);
- status.canPost = true;
- } else {
- alert('地图模式设置所有选项都是必填选项!请填写完整');
- status.canPost = false;
- return false;
- }
- return mapData;
- };
- /**
- * 保存设置 保存成功则刷新页面
- * @type {Function}
- * @returns {boolean}
- * @private
- */
- function saveSetting() {
- var ajaxData = {};
- /*var mapData = getMapFormData();
- ajaxData.mapSetting = mapData;
- var dxData = getDxFormData();
- ajaxData.dixing = dxData;
- var mxData = getMxFormData();
- ajaxData.moxing = mxData;*/
- var baseMap2DData = getMap2DFromData();
- if (!baseMap2DData) {
- return false
- }
- ajaxData.baseMap2D = baseMap2DData;
- var map2DThematicData = getDxFormData();
- if (!map2DThematicData) {
- return false
- }
- ajaxData.map2DThematicSetting = map2DThematicData;
- var map2DThematicCData = getThematicCategory();
- if (!map2DThematicCData) {
- return false
- }
- ajaxData.map2DThematicCategory = map2DThematicCData;
- var baseMap3DData = getMap3DFromData();
- if (!baseMap3DData) {
- return false
- }
- ajaxData.baseMap3D = baseMap3DData;
- var map3DModelSCData = getModel3DCategory();
- if (!map3DModelSCData) {
- return false
- }
- ajaxData.map3DModelSettingCategory = map3DModelSCData;
- var map3DModelSettingData = getMxFormData();
- if (!map3DModelSettingData) {
- return false
- }
- ajaxData.map3DModelSetting = map3DModelSettingData;
- var iGoalsCategorData = getImportantGC();
- if (!iGoalsCategorData) {
- return false
- }
- ajaxData.importantGoalsCategory = iGoalsCategorData;
- var iGoalsSettingData = getImportantData();
- if (!iGoalsSettingData) {
- return false
- }
- ajaxData.importantGoalsSetting = iGoalsSettingData;
- var kuozhanData = getKuozhanData();
- if (!kuozhanData) {
- return false
- }
- ajaxData.kuozhanLink = kuozhanData;
- if (status.canPost) {
- $.ajax({
- type: "post",
- dataType: 'json',
- url: onemapUrlConfig.gcmsServiceUrl + '/storage',
- data: {
- mapSetting: JSON.stringify(ajaxData)
- },
- beforeSend: ONEMAP.V.loading.load(),
- success: function (data) {
- console.log(data);
- if (window.confirm('保存成功,是否刷新页面应用设置?')) {
- location.reload(true);
- }
- },
- error: function (data) {
- alert('保存失败,请重试!');
- },
- completer: ONEMAP.V.loading.loaded()
- });
- }
- };
- function sanWeiList() {
- setLayout();
- // console.log($("#model3DList ul .mCSB_container").html());
- }
- return ONEMAP.M.setting = {
- init: init,
- linkAddIG: linkAddIG,
- sanWeiList: sanWeiList,
- addNewDxForm: addNewDxForm,
- bindEvent: bindEvent,
- buildDxForm: buildDxForm
- };
- });
|