wangzhibo
2021-09-24 696254697bba0fa3f13af4f686eaf8b7f09e1c43
add change layer style option
3个文件已修改
74 ■■■■■ 已修改文件
js/function.js 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
widgets/manageLayers_style/view.js 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
widgetsTS/dataTime/widget.js 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
js/function.js
@@ -3,7 +3,6 @@
var userid = '2';
var Vec_annoTileLayer;
var Img_annoTileLayer;
@@ -37,11 +36,33 @@
function getDefaultDateTime() {
  var now = new Date;
  now.setMinutes(now.getMinutes() - 60);
  return now.getFullYear + '-' + (now.getMonth() + 1) + '-' + now.getDate() + ' ' + now.getHours() + ':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";
}
console.log(mars3d.globel_variables);
mars3d.globel_variables = { geoserver_url_predix: 'http://58.246.27.194:7011/', userid: 2, queryDataType: 'hour' };
mars3d.globel_variables.queryDataTStart = getDefaultDateTime();
mars3d.globel_variables.queryDataTEnd = getDefaultDateTime();
mars3d.globel_variables.layer100600_conifg = { name: '街道', styleoptions: ['pm25', 'pm10'], selectedstyle: 'pm25' };
console.log(mars3d.globel_variables);
mars3d.reloadLayers = function (layerid){
  if (layerid ==100611) {
    addJiedaoLayer();
  }
};
function addTDTAnnoLayer() {
@@ -668,20 +689,25 @@
function addJiedaoLayer() {
  let tmpLyaer = map.getLayerById(100611);
  if (tmpLyaer) {
    map.removeLayer(tmpLyaer);
  }
  //方式2:在创建地球后调用addLayer添加图层(直接new对应type类型的图层类)
  layer_100611_jiedao = new mars3d.layer.WmsLayer({
    // id : 10,
    id: 100611,
    pid: 1006,
    name: "街道",
    name: mars3d.globel_variables.layer100600_conifg.name,
    type: "wms",
    url: "http://58.246.27.194:7011/geoserver/konglu_58/wms",
    layers: "konglu_58:vis_region_100611_hour",
    url: mars3d.globel_variables.geoserver_url_predix + "geoserver/konglu_58/wms",
    layers: "konglu_58:vis_region_100600_" + mars3d.globel_variables.queryDataType,
    crs: "EPSG:4326",
    parameters: {
      "Stayle":"polyline_road_pm25",
      "styles": "polygon_region_" + mars3d.globel_variables.layer100600_conifg.selectedstyle,
      "transparent": "true",
      "format": "image/png",
      "sld": "http://127.0.0.1:8080/geoserver/styles/polygon_region_pm25.sld"
      "viewparams": "userid:" + mars3d.globel_variables.userid + ";datatime:" + mars3d.globel_variables.queryDataTStart
    },
    center: {"lat":30.466245,"lng":121.562803,"alt":107679,"heading":356,"pitch":-58},
    getFeatureInfoParameters: {
@@ -699,10 +725,17 @@
      }),
    },
    popup: "all",
    show: false,
    selectedMapStyleOptions:'pm25',
    hasMapStyleOptions:['pm25','pm10','no','no2','nox','co'],
    flyTo: true
    show: true,
    selectedMapStyleOptions: mars3d.globel_variables.layer100600_conifg.selectedstyle,
    hasMapStyleOptions: mars3d.globel_variables.layer100600_conifg.styleoptions,
    flyTo: false,
    reloadLayers:function(new_style){
      console.log(new_style);
      mars3d.globel_variables.layer100600_conifg.selectedstyle = new_style;
      addJiedaoLayer();
    }
  });
  //单击事件
@@ -712,6 +745,7 @@
  map.addLayer(layer_100611_jiedao);
}
widgets/manageLayers_style/view.js
@@ -279,7 +279,7 @@
    for (var i = 0, len = item.length; i < len; i++) {
      radio_html += '<span class="button level1 switch center_docu" ></span><label><input type="radio" name="' + tNode.tId + '_style" value="" '+(item[i]==layer.options.selectedMapStyleOptions?"checked":"")+'/>'+item[i].toUpperCase()+'</label></br>';
      radio_html += '<span class="button level1 switch center_docu" ></span><label><input type="radio" name="' + tNode.tId + '_style" value="'+item[i]+'" ' + (item[i] == layer.options.selectedMapStyleOptions ? "checked" : "") + '/>' + item[i].toUpperCase() + '</label></br>';
    }
    radio_html +='</div>';
@@ -292,9 +292,7 @@
    $('input[type=radio][name='+ tNode.tId + '_style]').change(function() {
      var layer = layersObj[tNode.uuid];
        layer.options.selectedMapStyleOptions = this.value;
        mars3d.reloadLayers(layer.id);
      layer.options.reloadLayers(tmpValue);
      });
  }
widgetsTS/dataTime/widget.js
@@ -68,9 +68,13 @@
      if (window.top) {
        request = $.extend(request, haoutil.system.getRequest(window.top));
      }
      mars3d.globel_variables = { userid: request.userid || 2, queryDataType: 'hour' };
      console.log( mars3d.globel_variables);
      mars3d.globel_variables = { geoserver_url_predix:'http://58.246.27.194:7011/',userid: request.userid || 2, queryDataType: 'hour' };
      mars3d.globel_variables.queryDataTStart = this.defaultDateTime;
      mars3d.globel_variables.queryDataTEnd = this.defaultDateTime;
      mars3d.globel_variables.layer100600_conifg={name:'街道',styleoptions:['pm25','pm10'],selectedstyle:'pm25'};
      console.log( mars3d.globel_variables);
    }