"use script"; //开发环境建议开启严格模式
|
//系统 功能入口
|
|
|
// for change color locally.
|
var data_list_1001;
|
|
|
function addWMSLayer(item) {
|
var wmsLyer = new mars3d.layer.WmsLayer({
|
id: item.id,
|
pid: item.pid,
|
name: item.name,
|
type: "wms",
|
url: mars3d.global_variables.geoserver_url_predix + "geoserver/konglu_58/wms",
|
layers: "konglu_58:" + item.geoname_prefix + mars3d.global_variables.queryDataType,
|
crs: "EPSG:4326",
|
parameters: {
|
"styles": item.style_prefix + item.style_selected,
|
"transparent": "true",
|
"format": "image/png",
|
"viewparams": "userid:" + mars3d.global_variables.userid +";regiontype:" + item.regiontype + ";datetime:" + mars3d.global_variables.queryDataTStartGeo
|
},
|
getFeatureInfoParameters: {
|
feature_count: 10,
|
"viewparams": "userid:" + mars3d.global_variables.userid +";regiontype:" + item.regiontype + ";datetime:" + mars3d.global_variables.queryDataTStartGeo
|
},
|
center: { "lat": 30.487351, "lng": 121.613269, "alt": 54033, "heading": 359, "pitch": -40 },
|
noCenter: true,
|
maxLength: 35000,
|
//单击高亮及其样式
|
highlight: {
|
type: "wallP",
|
diffHeight: 300,
|
material: mars3d.MaterialUtil.createMaterial(mars3d.MaterialType.LineFlow, {
|
image: "img/textures/fence.png",
|
color: "#ffff00",
|
speed: 10, //速度,建议取值范围1-100
|
axisY: true,
|
}),
|
},
|
show: item.show,
|
geoname_prefix: item.geoname_prefix,
|
style_prefix: item.style_prefix,
|
style_selected: item.style_selected,
|
style_options: item.styleoptions,
|
regiontype:item.regiontype,
|
flyTo: false,
|
zIndex:item.zIndex
|
});
|
|
|
if (item.minimumLevel !=undefined){
|
wmsLyer.options.minimumLevel = item.minimumLevel;
|
wmsLyer.options.minimumTerrainLevel = item.minimumLevel;
|
}
|
if (item.maximumLevel !=undefined){
|
wmsLyer.options.maximumLevel = item.maximumLevel;
|
wmsLyer.options.maximumTerrainLevel = item.maximumLevel;
|
}
|
|
wmsLyer.bindPopup(bindPopupFunction);
|
|
//单击事件
|
wmsLyer.on(mars3d.EventType.click, function (event) {
|
console.log("单击了矢量数据,共" + event.features.length + "条", event);
|
var id = event.layer.options.id;
|
var qindex = event.layer.options.style_selected;
|
event.graphic.style.diffHeight = qindex == 'co' ? 10 * event.graphic.attr[qindex] : event.graphic.attr[qindex];
|
//event.graphic.style.material.uniforms.color = getLayerPointColorByQindexandValue(id, qindex, event.graphic.attr[qindex]);
|
//event.graphic.style.material.uniforms.color = getLayerPointColorByQindexandValue(id, qindex, event.graphic.attr[qindex]);
|
event.graphic.style.material = new mars3d.MaterialUtil.createMaterial(mars3d.MaterialType.LineFlow, {
|
image: "img/textures/fence.png",
|
color: getLayerPointColorByQindexandValue(id, qindex, event.graphic.attr[qindex]),
|
speed: 10, //速度,建议取值范围1-100
|
axisY: true,
|
})
|
mars3d.global_variables.tmpHighlightGraphics = event.graphics;
|
});
|
|
map.addLayer(wmsLyer);
|
|
}
|
|
function addGuokongLayerDIV(item) {
|
|
var guokongLayer = new mars3d.layer.DivLayer({
|
id: item.id,
|
pid: item.pid, //图层管理 中使用,父节点id
|
name: item.name,
|
style_selected: item.style_selected,
|
style_options: item.styleoptions,
|
show: item.show,
|
});
|
map.addLayer(guokongLayer);
|
|
guokongLayer.on(mars3d.EventType.click, function (event) {
|
console.log("监听layer,单击了矢量对象", event);
|
console.log(event.graphic)
|
var item = event.graphic?.attr;
|
mars3d.global_variables.tmpHighlightGraphics = event.graphics;
|
|
});
|
|
guokongLayer.bindPopup(bindPopupFunction);
|
|
guokongLayer.changeColor = function () {
|
guokongLayer.clear(true);
|
addGuokongPointResutToLayer(this, data_list_1001);
|
}
|
// add 国控点
|
getGuokongPointFromServer(guokongLayer);
|
|
}
|
|
function getGuokongPointFromServer(tmplayer) {
|
|
$.getJSON(mars3d.global_variables.nodejs_url_predix + "dataapi/Bdata?bid=get_1001_list&datatype=" + mars3d.global_variables.queryDataType + "&datatime=" + mars3d.global_variables.queryDataTStart + "®ionCode="+mars3d.global_variables.regionCode+"&qindex=pm25&pageno=1&pagesize=1000", (result) => {
|
data_list_1001 = result.data.result;
|
addGuokongPointResutToLayer(tmplayer, result.data.result);
|
});
|
|
}
|
|
function addGuokongPointResutToLayer(tmplayer, items) {
|
for (var i = 0, len = items.length; i < len; i++) {
|
var item = items[i];
|
var jd = item.lon;
|
var wd = item.lat;
|
var clr = getLayerPointColorByQindexandValue(tmplayer.options.id, tmplayer.options.style_selected, item[tmplayer.options.style_selected]);
|
var graphic = new mars3d.graphic.DivLightPoint({
|
position: Cesium.Cartesian3.fromDegrees(jd, wd),
|
style: {
|
color: clr,
|
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
|
highlight: {
|
type: "circleP",
|
style: {
|
radius: 2000,
|
material: mars3d.MaterialUtil.createMaterial(mars3d.MaterialType.ScanLine, {
|
color: new Cesium.Color(1.0, 1.0, 0.0, 1.0),
|
speed: 10,
|
}),
|
clampToGround: true, //是否贴地
|
}
|
}
|
},
|
show: true,
|
attr: item,
|
});
|
tmplayer.addGraphic(graphic);
|
}
|
}
|
|
|
|
function getLayerPointColorByQindexandValue(layerid, qindex, value) {
|
|
if (!value || value == null || value == 'null') {
|
return allLayer_color_nodata;
|
}
|
if (layerid == 1001) {
|
return getColorByListandValue(qindex_range_list_1001, color_list_1001, qindex, value);
|
} else if (layerid == 1002) {
|
return getColorByListandValue(qindex_range_list_1002, color_list_1002, qindex, value);
|
} else if (layerid == 1003) {
|
return getColorByListandValue(qindex_range_list_1003, color_list_1003, qindex, value);
|
} else {
|
return getColorByListandValue(qindex_range_list_1004_and_other, color_list_1004_and_other, qindex, value);
|
}
|
}
|
|
function getColorByListandValue(rangList, colorList, tmpQindex, tmpValue) {
|
for (var key in rangList) {
|
if (key == tmpQindex) {
|
for (let i = rangList[key].length; i > -1; i--) {
|
if (tmpValue > rangList[key][i]) {
|
return colorList[i + 1];
|
}
|
}
|
}
|
}
|
return colorList[0];
|
}
|
|
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;
|
}
|
|
function timetype_change1(){
|
if(mars3d.global_variables.timetype == "min"){
|
$(".menu1").attr('onclick'," "); //$("#名称").attr("属性名","属性值");
|
haoutil.msg("请切换至天或时查看数据!!!");
|
}else{
|
$(".menu1").attr('onclick',"javascript:activateWidget('widgetsTS/widget_summary/widget.js')"); //$("#名称").attr("属性名","属性值");
|
}
|
}
|
function timetype_change2(){
|
if(mars3d.global_variables.timetype == "min"){
|
$(".menu2").attr('onclick'," "); //$("#名称").attr("属性名","属性值");
|
haoutil.msg("请切换至天或时查看数据!!!");
|
}else{
|
$(".menu2").attr('onclick',"javascript:activateWidget('widgetsTS/widget_search/widget.js')"); //$("#名称").attr("属性名","属性值");
|
}
|
}
|
function timetype_change3(){
|
if(mars3d.global_variables.timetype == "min"){
|
$(".menu3").attr('onclick'," "); //$("#名称").attr("属性名","属性值");
|
haoutil.msg("请切换至天或时查看数据!!!");
|
}else{
|
$(".menu3").attr('onclick',"javascript:activateWidget('widgetsTS/widget_grid/widget.js')"); //$("#名称").attr("属性名","属性值");
|
}
|
}
|
|
function timetype_change4(){
|
if(mars3d.global_variables.timetype == "min"){
|
$(".menu4-Wind").attr('onclick'," "); //$("#名称").attr("属性名","属性值");
|
haoutil.msg("请切换至天或时查看数据!!!");
|
}else{
|
$(".menu4-Wind").attr('onclick',"javascript:activateWidget('widgetsTS/windsetting/widget.js');javascript:$('#menu4Child').toggle()"); //$("#名称").attr("属性名","属性值");
|
}
|
}
|
|
function timetype_change5(){
|
// if(mars3d.global_variables.timetype == "min"){
|
// $(".menu5-Taxirouter").attr('onclick'," "); //$("#名称").attr("属性名","属性值");
|
// haoutil.msg("请切换至天或时查看数据!!!");
|
// }else{
|
$(".menu5-Taxirouter").attr('onclick',"javascript:activateWidget('widgetsTS/taxiRouteReplay2/widget.js');javascript:$('#menu4Child').toggle()"); //$("#名称").attr("属性名","属性值");
|
// }
|
}
|