cshenfu
2022-10-31 c9179aa494559b7d376d1d473b3720ae61c1defe
noChange
6个文件已修改
200 ■■■■ 已修改文件
config/config.json 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
data/getLayerListByUserid.json 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
js/function_1004.js 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
js/index.js 156 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
widgetsTS/taxiRouteReplay/view.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
widgetsTS/taxiRouteReplay/widget.js 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
config/config.json
@@ -47,7 +47,6 @@
      "geocoder": false,
      "geocoderConfig": { "key": ["ae29a37307840c7ae4a785ac905927e0"] },
      "selectionIndicator": false,
      "defaultContextMenu": true,
      "mouseDownView": true,
      "compass": { "bottom": "270px", "right": "5px" },
@@ -82,17 +81,34 @@
        "icon": "img/basemaps/tdt_vec.png",
        "type": "group",
        "layers": [
          { "name": "底图", "type": "tdt", "layer": "vec_d", "key": ["51915011aa0997aa2ddd7e38504fa8bc"] }
          {
            "name": "底图",
            "type": "tdt",
            "layer": "vec_d",
            "key": ["51915011aa0997aa2ddd7e38504fa8bc"]
          }
        ],
        "zIndex": 0
      },
      {
        "pid": 10,
        "name": "黑色底图",
        "icon": "/img/basemaps/bd-c-dark.png",
        "type": "tencent",
        "layer": "custom",
        "style": "4"
        "icon": "img/basemaps/bd-c-dark.png",
        "type": "group",
        "layers": [
          {
            "name": "底图",
            "type": "tdt",
            "layer": "vec_d",
            "brightness": 0.3,
            "contrast": 1.8,
            "gamma": 1,
            "hue": 0,
            "saturation": 0,
            "key": ["51915011aa0997aa2ddd7e38504fa8bc"]
          }
        ],
        "zIndex": 0
      }
    ],
    "layers": [
@@ -114,6 +130,7 @@
        "layer": "time",
        "minimumTerrainLevel": 4,
        "minimumLevel": 4,
        "proxy": "//server.mars3d.cn/proxy/",
        "mapSplit": false
      },    
      { "id": 99, "name": "数据图层", "type": "group" },
data/getLayerListByUserid.json
@@ -231,11 +231,10 @@
            "style_selected":"pm25",
            "styleoptions": ["pm25", "pm10", "no", "no2", "nox", "co"],
            "regiontype":"00",
            "minimumLevel":8,
            "minimumLevel":11,
            "maximumLevel":12,
            "show":false,
            "zIndex":6
        },
        {
            "id": 3003,
@@ -247,8 +246,8 @@
            "style_selected":"pm25",
            "styleoptions": ["pm25", "pm10", "no", "no2", "nox", "co"],
            "regiontype":"00",
            "minimumLevel":6,
            "maximumLevel":7,
            "minimumLevel":8,
            "maximumLevel":10,
            "show":false,
            "zIndex":7
js/function_1004.js
@@ -66,10 +66,10 @@
      if (current_date.getSeconds() != last_time_second) {
        console.log("current_data != ")
        last_time_second = current_date.getSeconds();
        console.log(current_date,"current_data  data")
        changeTaxiLayerStyleAndAttr_Single(getFormattedDateTime(current_date));
      }
    } else if (map.getLayerById(1004).options.show) {
      console.log("current_data ==")
      var current_date = new Date(Cesium.JulianDate.toDate(event._currentTime));
      if (current_date.getSeconds() != last_time_second) {
        last_time_second = current_date.getSeconds();
@@ -108,10 +108,12 @@
  var taxi_qindex = map.getLayerById(1004).options.style_selected;
  let single_taxi = taxi_layer.getGraphicById(mars3d.global_variables.singleTaxiReplayData[0]["code"]);
  if (!single_taxi) {
    console.log("进入第一个if")
    var tmpPositionProperty = new Cesium.SampledPositionProperty();
    for (var i = 0, len = mars3d.global_variables.singleTaxiReplayData.length; i < len; i++) {
      let item = mars3d.global_variables.singleTaxiReplayData[i];
      tmpPositionProperty.addSample(Cesium.JulianDate.fromDate(new Date(item["datatime"])), Cesium.Cartesian3.fromDegrees(item["lon"], item["lat"], 0.2))
      console.log(tmpPositionProperty,"汽车路线经纬度")
    }
    single_taxi = new mars3d.graphic.ModelEntity({
@@ -148,6 +150,7 @@
  }
  tmpattr = getTaxiAttrFromTimeListData(current_date, mars3d.global_variables.singleTaxiReplayData);
  if (tmpattr && tmpattr != null) {
    console.log("进入第二个if")
    let tmpTaxiColor = getLayerPointColorByQindexandValue(1004, taxi_qindex, tmpattr[taxi_qindex]);
    let tmpTaxigltfurl = "gltf/" + (tmpattr["code"]).substring(0, 2) + tmpTaxiColor.substring(1) + ".gltf";
    single_taxi.setOptions({
js/index.js
@@ -1,67 +1,69 @@
"use script"; //开发环境建议开启严格模式
//系统主入口
var map; //地球对象
var request; //传入的get参数
var geoJsonLayer;
//地图
$(document).ready(function () {
  //判断webgl支持
  if (!mars3d.Util.webglreport()) {
    mars3d.Util.webglerror();
  }
  //记录url传入参数
  request = haoutil.system.getRequest();
  if (window.top) {
    //有父级
    request = $.extend(request, haoutil.system.getRequest(window.top));
  }
  // try {
  //   var jwtstr = request.JWT;
  //   var strs_ = jwtstr.split('.');
  //   var jwt_header_ = new buffer.Buffer(strs_[0].toString('base64'), 'base64').toString();
  //   var jwt_payload_ = new buffer.Buffer(strs_[1].toString('base64'), 'base64').toString();
  //   var payload_ = JSON.parse(jwt_payload_);
  //   mars3d.global_variables.userid = payload_.userid;
  //   mars3d.global_variables.regionCode = payload_.divcode;
  //   var hash = CryptoJS.HmacSHA256(strs_[0] + '.' + strs_[1], "sxyd");
  //   var hashInBase64 = base64UrlEncode(hash);
  //   var reg = RegExp(strs_[2]);
  //   if (!reg.exec(hashInBase64)) {
  //     // verification failed, go back
  //     window.top.location = mars3d.global_variables.un_authorization_url;
  //   }
  //   payload_ = JSON.parse(jwt_payload_);
  //   if (!payload_ || !payload_.expires) {
  //     // verification error ,go back
  //     window.top.location = mars3d.global_variables.un_authorization_url;
  //   }
  //   var date1 = new Date(payload_.expires);
  //   var date2 = new Date();
  //   if (date1 < date2) {
  //     // expire, go back
  //     window.top.location = mars3d.global_variables.un_authorization_url;
  //   }
  // }
  // catch (err) {
  //   window.top.location = mars3d.global_variables.un_authorization_url;
  // }
  mars3d.global_variables.userid = request?.userid || 2;
  try {
    var jwtstr = request.JWT;
    var strs_ = jwtstr.split('.');
    var jwt_header_ = new buffer.Buffer(strs_[0].toString('base64'), 'base64').toString();
    var jwt_payload_ = new buffer.Buffer(strs_[1].toString('base64'), 'base64').toString();
    var payload_ = JSON.parse(jwt_payload_);
    mars3d.global_variables.userid = payload_.userid;
    mars3d.global_variables.regionCode = payload_.divcode;
    var hash = CryptoJS.HmacSHA256(strs_[0] + '.' + strs_[1], "sxyd");
    var hashInBase64 = base64UrlEncode(hash);
    var reg = RegExp(strs_[2]);
    if (!reg.exec(hashInBase64)) {
      // verification failed, go back
      window.top.location = mars3d.global_variables.un_authorization_url;
    }
    payload_ = JSON.parse(jwt_payload_);
    if (!payload_ || !payload_.expires) {
      // verification error ,go back
      window.top.location = mars3d.global_variables.un_authorization_url;
    }
    var date1 = new Date(payload_.expires);
    var date2 = new Date();
    if (date1 < date2) {
      // expire, go back
      window.top.location = mars3d.global_variables.un_authorization_url;
    }
  }
  catch (err) {
    window.top.location = mars3d.global_variables.un_authorization_url;
  }
  if(!mars3d.global_variables.userid) {
    mars3d.global_variables.userid = 2;
  }
  regionCode = mars3d.global_variables.regionCode
  var configfile = "config/config.json"; //默认地址
  if (request.config) {
    //url传入地址
    configfile = request.config;
  }
  haoutil.loading.show();
  $.ajax({
    type: "get",
    dataType: "json",
@@ -69,10 +71,10 @@
    timeout: 0,
    success: function (data) {
      haoutil.loading.hide();
      //构建地图
      initMap(data.map3d);
      setTimeout(removeMask, 3000); //欢迎UI关闭处理
    },
    error: function (request, textStatus) {
@@ -82,50 +84,50 @@
      console.log(textStatus, request);
    },
  });
  initUI();
});
function removeMask() {
  $("#mask").remove();
}
//UI界面相关
function initUI() {
  haoutil.oneMsg("首次访问系统无缓存会略慢,请耐心等待!", "load3d_tip");
}
//初始化地图
function initMap(mapOptions) {
  //合并属性参数,可覆盖config.json中的对应配置
  // mapOptions = mars3d.Util.merge(mapOptions, {})
  //创建三维地球场景
  map = new mars3d.Map("mars3dContainer", mapOptions);
  //构造widget
  initWidget(map);
  initLayersByUserid();
  //如果有xyz传参,进行定位
  if (haoutil.isutil.isNotNull(request.x) && haoutil.isutil.isNotNull(request.y)) {
    map.setCameraView(request, { duration: 0, isWgs84: true });
  }
  //开场动画
  //map.openFlyAnimation();
  //针对不同终端的优化配置
  if (haoutil.system.isPCBroswer()) {
    // Cesium 1.61以后会默认关闭反走样,对于桌面端而言还是开启得好,
    map.scene.postProcessStages.fxaa.enabled = true;
    //鼠标滚轮放大的步长参数
    map.scene.screenSpaceCameraController._zoomFactor = 2.0;
    //IE浏览器优化
    if (window.navigator.userAgent.toLowerCase().indexOf("msie") >= 0) {
      map.viewer.targetFrameRate = 20; //限制帧率
@@ -134,34 +136,34 @@
  } else {
    //鼠标滚轮放大的步长参数
    map.scene.screenSpaceCameraController._zoomFactor = 5.0;
    //移动设备上禁掉以下几个选项,可以相对更加流畅
    map.viewer.requestRenderMode = true; //取消实时渲染
    map.scene.fog.enabled = false;
    map.scene.skyAtmosphere.show = false;
    map.scene.globe.showGroundAtmosphere = false;
  }
  //二三维切换不用动画
  if (map.sceneModePicker) {
    map.sceneModePicker.viewModel.duration = 0.0;
  }
  //webgl渲染失败后,刷新页面
  // map.on(mars3d.EventType.renderError, function (scene, error) {
  //   window.location.reload();
  // });
  //绑定单击显示BIM的构件树
  bindShowTilesParts();
  //下面可以继续加项目相关的其他代码
}
//初始化widget相关
function initWidget(map) {
  haoutil.loading.show();
  $.ajax({
    type: "get",
    dataType: "json",
@@ -169,7 +171,7 @@
    timeout: 0,
    success: function (widgetCfg) {
      haoutil.loading.hide();
      //url如果有传参时的处理
      if (haoutil.isutil.isNotNull(request.widget)) {
        if (request.onlyStart) {
@@ -185,10 +187,10 @@
        });
        map.flyHome({ duration: 0 });
      }
      //初始化widget管理器
      mars3d.widget.init(map, widgetCfg, "./"); //tip: 第3个参数支持定义widget目录的相对路径。
      if (window.lastWidgetItem) {
        activateWidget(lastWidgetItem);
        lastWidgetItem = null;
@@ -199,7 +201,7 @@
      haoutil.alert("config/widget.json文件加载失败!");
    },
  });
  //widget相关事件监听
  // mars3d.widget.on(mars3d.widget.EventType.load, function (event) {
  //     console.log("引入加载了widget的js", event);
@@ -207,7 +209,7 @@
  // mars3d.widget.on(mars3d.widget.EventType.beforeCreate, function (event) {
  //     console.log("不创建widet", event);
  // }) 
  mars3d.widget.on(mars3d.widget.EventType.activated, function (event) {
    console.log("激活了widget", event);
  });
@@ -215,7 +217,7 @@
    console.log("释放了widget", event);
  });
}
//bim构件的处理
function bindShowTilesParts() {
  //单击地图事件
@@ -224,15 +226,15 @@
      //不是BIM数据时跳出
      return;
    }
    let layer = event.layer;
    if (!layer.options.scenetree) {
      //未配置scenetree时跳出
      return;
    }
    var tilesParts = "widgets/tilesParts/widget.js";
    if (mars3d.widget.isActivate(tilesParts)) {
      var parts = mars3d.widget.getClass(tilesParts);
      if (parts.config.layerCfg == layer.options) {
@@ -240,7 +242,7 @@
        return;
      }
    }
    mars3d.widget.activate({
      name: layer.name + " 构件",
      uri: tilesParts,
@@ -249,7 +251,7 @@
    });
  });
}
//外部页面调用
var lastWidgetItem;
function activateWidget(item) {
@@ -265,15 +267,15 @@
function activateFunByMenu(fun) {
  eval(fun);
}
function goHome() {
  mars3d.widget.disableAll();
  map.flyHome();
}
function base64UrlEncode(str) {
  var encodedSource = CryptoJS.enc.Base64.stringify(str);
  var reg = new RegExp('/', 'g');
  encodedSource = encodedSource.replace(/=+$/,'').replace(/\+/g,'-').replace(reg,'_');
  return encodedSource;
}
}
widgetsTS/taxiRouteReplay/view.js
@@ -52,7 +52,6 @@
  //开始查询轨迹
  $("#startQueryTaxiData").click(function () {
    console.log(thisWidget,"thisWidget")
    haoutil.loading.show();
    thisWidget.appDateHourStart = $("#appDateHourStart").val()
    thisWidget.appDateHourEnd = $("#appDateHourEnd").val()
widgetsTS/taxiRouteReplay/widget.js
@@ -220,7 +220,6 @@
    //每个窗口创建完成后调用
    winCreateOK(opt, result) {
      this.viewWindow = result;
      console.log(this,"this.taxi_sn")
      this.appDateHourStart = mars3d.global_variables.queryDataTStartTaxi;
      this.appDateHourEnd = mars3d.global_variables.queryDataTEnd;
      this.nodejs_url_predix = mars3d.global_variables.nodejs_url_predix;
@@ -230,7 +229,6 @@
    }
    //打开激活
    activate() {
      console.log(this,"this  detail")
      this.map.addLayer(this.groupLayer);
      this.map.clock.shouldAnimate = false;
      this.old_map_clock_startTime = this.map.clock.startTime;