/** * @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 = $('
  • 名称:

    链接:

  • '); liDom.appendTo($("#kzList")); } } }; /** * 界面事件绑定 * @return {[type]} [description] */ function bindEvent() { //添加拓展服务 $(".add-kz").bind("click", function () { var liDom = $('
  • 名称:

    链接:

  • '); 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 = $("
  • 新分类" + "
    " + "编辑" + "删除" + "
    " + "
    " + "" + "确定" + "取消" + "
    " + "
  • "); 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)); $("
  • " + item.name + "
  • ").appendTo($("#iGNameList ul")); }); var chooseHtml = $(''); for (var i = 0; i < ONEMAP.D.globalSettingData.importantGoalsCategory.length; i++) { var liHtml = $('
  • ' + ONEMAP.D.globalSettingData.importantGoalsCategory[i] + '
  • '); $(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)); } $("
  • " + item.name + "
  • ").appendTo($("#thematicList ul")); }); var chooseHtml = $(''); for (var i = 0; i < ONEMAP.D.globalSettingData.map2DThematicCategory.length; i++) { var liHtml = $('
  • ' + ONEMAP.D.globalSettingData.map2DThematicCategory[i] + '
  • '); $(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 = $(''); for (var i = 0; i < ONEMAP.D.globalSettingData.map2DThematicCategory.length; i++) { var liHtml = $('
  • ' + ONEMAP.D.globalSettingData.map2DThematicCategory[i] + '
  • '); $(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)); } $("
  • " + item.name + "
  • ").appendTo($("#model3DList ul")); }) var chooseHtml = $(''); for (var i = 0; i < ONEMAP.D.globalSettingData.map3DModelSettingCategory.length; i++) { var liHtml = $('
  • ' + ONEMAP.D.globalSettingData.map3DModelSettingCategory[i] + '
  • '); $(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 = $(''); for (var i = 0; i < ONEMAP.D.globalSettingData.importantGoalsCategory.length; i++) { var liHtml = $('
  • ' + ONEMAP.D.globalSettingData.importantGoalsCategory[i] + '
  • '); $(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 = $('
  • ' + tdSet[i].layer_name + '
  • '); $("#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 = $('
  • ' + tdSetQ[i].layer_name + '
  • '); $("#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 = $(''); for (var i = 0; i < ONEMAP.D.globalSettingData.map3DModelSettingCategory.length; i++) { var liHtml = $('
  • ' + ONEMAP.D.globalSettingData.map3DModelSettingCategory[i] + '
  • '); $(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++) { $("
  • " + data[i] + "" + "
    " + "编辑" + "删除" + "
    " + "
    " + "" + "确定" + "取消" + "
    " + "
  • ").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++) { $("
  • " + data[i] + "" + "
    " + "编辑" + "删除" + "
    " + "
    " + "" + "确定" + "取消" + "
    " + "
  • ").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++) { $("
  • " + data[i] + "" + "
    " + "编辑" + "删除" + "
    " + "
    " + "" + "确定" + "取消" + "
    " + "
  • ").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 = $(''); for (var i = 0; i < ONEMAP.D.globalSettingData.importantGoalsCategory.length; i++) { var liHtml = $('
  • ' + ONEMAP.D.globalSettingData.importantGoalsCategory[i] + '
  • '); $(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 }; });