"use script"; //开发环境建议开启严格模式 //系统 功能入口 function getDefaultDateTime() { // return "2021-07-01 12:00:00"; var date = new Date; date.setHours(date.getHours() - 2); var year = date.getFullYear();//年 var month = date.getMonth();//月 var day = date.getDate();//日 var hours = date.getHours();//时 return year + "-" + ((month + 1) > 9 ? (month + 1) : "0" + (month + 1)) + "-" + (day > 9 ? day : ("0" + day)) + " " + (hours > 9 ? hours : ("0" + hours)) + ":00:00"; } function getDefaultDateTimeEnd() { // return "2021-07-01 12:15:00"; var date = new Date; date.setHours(date.getHours() - 2); var year = date.getFullYear();//年 var month = date.getMonth();//月 var day = date.getDate();//日 var hours = date.getHours();//时 return year + "-" + ((month + 1) > 9 ? (month + 1) : "0" + (month + 1)) + "-" + (day > 9 ? day : ("0" + day)) + " " + (hours > 9 ? hours : ("0" + hours)) + ":15:00"; } function getDefaultDateTimeStart() { var date = new Date; date.setHours(date.getHours() - 10); var year = date.getFullYear();//年 var month = date.getMonth();//月 var day = date.getDate();//日 var hours = date.getHours();//时 return year + "-" + ((month + 1) > 9 ? (month + 1) : "0" + (month + 1)) + "-" + (day > 9 ? day : ("0" + day)) + " " + (hours > 9 ? hours : ("0" + hours)) + ":00:00"; } function getDefaultDateTimeGeo() { var date = new Date; date.setHours(date.getHours() - 2); var year = date.getFullYear();//年 var month = date.getMonth();//月 var day = date.getDate();//日 var hours = date.getHours();//时 return (year +"")+ ((month + 1) > 9 ? (month + 1) : "0" + (month + 1)) + (day > 9 ? day : ("0" + day)) + (hours > 9 ? hours : ("0" + hours)) + "0000"; } mars3d.global_variables = default_system_params; mars3d.global_variables.grid_camerview =default_grid_camerview; mars3d.global_variables.queryDataTStart = getDefaultDateTime(); mars3d.global_variables.queryDataTStartGeo = getDefaultDateTimeGeo(); mars3d.global_variables.queryDataTEnd = getDefaultDateTimeEnd(); mars3d.global_variables.DefaultDateTimeStart = getDefaultDateTimeStart(); // for tmp hight light graphic and //mars3d.global_variables.tmpHighlightGraphic; //mars3d.global_variables.tmpHighlightGraphicLayer; function initLayersByUserid() { //addMaskShanghai(); addTDTAnnoLayer(); addHighlightLayerClearButton(); addTmpHighlightGraphicLayer(); //TODO $.getJSON("data/getLayerListByUserid.json", { userid: mars3d.global_variables.userid }, (result) => { result.data.forEach((item) => { if ([item['type']] == 'wms') { addWMSLayer(item); } else if ([item['type']] == 'wind') { addWindLayer(item); } else if ([item['type']] == 'graphic') { //addGuokongLayer(item); addGuokongLayerDIV(item) } else if ([item['type']] == 'taxi') { addTaxiLayer(item); } }); }); } function reLoadLayers() { var layers = map.getLayers({ layers: true }); layers.forEach((layer) => { // console.log(layer.name + ":" + layer.type); if ([layer.type] == 'wms') { layer.options.layers = "konglu_58:" + layer.options.geoname_prefix + mars3d.global_variables.queryDataType; layer.options.parameters.viewparams = "userid:" + mars3d.global_variables.userid + ";regiontype:" + layer.options.regiontype + ";datetime:" + mars3d.global_variables.queryDataTStartGeo layer.options.getFeatureInfoParameters.viewparams = "userid:" + mars3d.global_variables.userid + ";regiontype:" + layer.options.regiontype + ";datetime:" + mars3d.global_variables.queryDataTStartGeo layer.reload(); } else if ([layer.id] == 1001 && layer.options.show) { var tmpguokong = map.getLayerById(1001); tmpguokong.clear(true); getGuokongPointFromServer(tmpguokong); //graphiclayer.eachGraphic } else if ([layer.id] == 1004 && layer.options.show) { var tmpTaxi = map.getLayerById(1004); tmpTaxi.clear(true); setTaxiLayerMapClock(); for (var i = 0, len = data_list_1004.length; i < len; i++) { getTaxiPathFromServerbySN(data_list_1004[i], tmpTaxi); } } }); } function refreshWidgets() { refreshSingleWidget("widgetsTS/weather/widget.js", {}); refreshSingleWidget("widgetsTS/widget_summary/widget.js", {}); refreshSingleWidget("widgetsTS/widget_search/widget.js", {}); } function refreshSingleWidget(widget_path, params) { if (mars3d.widget.isActivate(widget_path)) { var tempWiget = mars3d.widget.getClass(widget_path); tempWiget.reloadData(params); } } function addGraphictoHighlightLayer() { mars3d.global_variables.tmpHighlightGraphicLayer.addGraphic(mars3d.global_variables.tmpHighlightGraphic); } function addHighlightLayerClearButton() { let clearButton = new mars3d.control.ToolButton({ title: "清除高亮图层", icon: "fa fa-crop", insertIndex: 1, //插入的位置顺序, 1是home按钮后面 click: (event) => { mars3d.global_variables.tmpHighlightGraphicLayer.clear(true); }, }); map.addControl(clearButton); } function showDetail(layerid, itemCode, qindex) { if (mars3d.widget.isActivate("widgetsTS/widget_detail/widget.js")) { var detailWiget = mars3d.widget.getClass("widgetsTS/widget_detail/widget.js"); detailWiget.reloadData({ "nodejs_url_predix": mars3d.global_variables.nodejs_url_predix, "datatype": mars3d.global_variables.queryDataType, "selected_qindex": qindex, "datatime": mars3d.global_variables.queryDataTStart, "layerid": layerid, "siteid": itemCode }); } else { mars3d.widget.activate({ uri: "widgetsTS/widget_detail/widget.js", params: { "nodejs_url_predix": mars3d.global_variables.nodejs_url_predix, "datatype": mars3d.global_variables.queryDataType, "selected_qindex": qindex, "datatime": mars3d.global_variables.queryDataTStart, "layerid": layerid, "siteid": itemCode }, }); } } function showHistoryPathDetail(itemCode) { if (mars3d.widget.isActivate("widgetsTS/taxiRouteReplay/widget.js")) { var detailWiget = mars3d.widget.getClass("widgetsTS/taxiRouteReplay/widget.js"); detailWiget.reloadData(itemCode); } else { mars3d.widget.activate({ uri: "widgetsTS/taxiRouteReplay/widget.js", params: itemCode, }); } } function changeNullAndundefinedToEmpty(json_in) { for (var key in json_in) { if (json_in[key] == null || json_in[key] == 'null' || json_in[key] == undefined || json_in[key] == 'undefined') { json_in[key] = "/"; } } return json_in; }