zhanmingkan
2022-05-14 0fc43fe898d14895c97427801293edfb3a0c5bf1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
document.write('<script src="../js/man_service.js"></script>');
/*
 * 人员监督:实时定位和轨迹方法
 */
var deviceListMan=[];
var police3DInterval;
//构建人员目录树方法
function createManZTree(data,count){
    //构建目录树
    var treeObjList = null;
    if (data !== undefined || data != null) {
        var setting = {
            check : {
                enable : true,
                autoCheckTrigger : true,
                chkboxType : { "Y" : "s", "N" : "s" }
            },
            data : {
                simpleData : {
                    enable : true
                }
            },
            callback : {
                onCheck : policePeopleTreeChecked,
                onClick : policeLayerzTreeOnClick,
            },
            view : {
                showIcon : showIconForTree,
                selectedMulti : true,     //可以多选
                fontCss : setFontCss      //状态颜色回调函数
            }
        };
        var treeListArray = [];
        var treeName = "人员目录树 "+" (共"+count+"名)";
        var pNode = {id:0, pId:"", name:treeName, isNode:false, icon:"../images/treeicon/police1.png"};
        treeListArray.push(pNode);
        for (var i = 0; i < data.length; i++) {
            var treeObj = {};
            treeObj.id = data[i].policeId;
            treeObj.pId = 0;
            treeObj.name = data[i].name+"("+data[i].origin+")";
            treeObj.highlight = false;
            treeObj.isNode = true;
            treeObj.phone = data[i].deviceNum;
            treeObj.deviceType = data[i].deviceType;
            treeListArray.push(treeObj);
        }
        treeObjList = $.fn.zTree.init($("#policeTree"), setting, treeListArray);
        police3DInterval = window.setInterval(function(){
            getGpsRealdata(deviceListMan);
        },30000);
        //父节点显示图标
        function showIconForTree(treeId, treeNode) {
            return treeNode.isParent == true;
        }
        //点击复选框颜色变换的回调函数
        function setFontCss(treeId, treeNode) {
            return treeNode.checked == true ? {color:"white"} : {color:"gray"};
        };
        //check触发回调函数
        function policePeopleTreeChecked(event, treeId, treeNode) {
            var node = treeObjList.getNodeByParam('id',treeNode.id,null);
            treeObjList.updateNode(node);
            treeObjList.reAsyncChildNodes(node,'refresh',false);
            if(treeNode.level!=0){
                if(treeNode.checked){
                    if(deviceListMan.length==0||deviceListMan.indexOf(treeNode.phone)==-1){
                        deviceListMan.push(treeNode.phone);
                    }
                    getGpsRealdata(deviceListMan);
                }else{
                    deviceListMan.splice(deviceListMan.indexOf(treeNode.phone),1);
                    viewer.entities.removeById('po'+treeNode.phone);
                    closeVideoPop(treeNode.phone);
                }
            }
        }
    }
}
//停止刷新人员位置
function stopFreshPolicePos(){
    window.clearInterval(police3DInterval);
}
//人员目录树点击定位方法
function policeLayerzTreeOnClick(event, treeId, treeNode) {
    getManPosByDn(treeNode.phone);
}
//创建人员标签
var police3D_marks = [];
function createPolicePin(url,id,point,policeName){
    var policePin = viewer.entities.getById('po'+id);
    if(policePin == undefined){
        police3D_marks.push(viewer.entities.add({
            name : '人员',
            id : 'po'+id,
            position : point,
            billboard : {
                image : url,
                verticalOrigin : Cesium.VerticalOrigin.BOTTOM,
                pixelOffset : new Cesium.Cartesian2(36.0, 0.0),
                scaleByDistance : new Cesium.NearFarScalar(1000, 1, 20000, 0.2),
                pixelOffsetScaleByDistance : new Cesium.NearFarScalar(1000, 1, 20000, 0.2),
            },
            label : {
                show : true,
                verticalOrigin : Cesium.VerticalOrigin.BOTTOM,
                horizontalOrigin : Cesium.HorizontalOrigin.CENTER,
                font : 'bold 16px Helvetica',
                fillColor : Cesium.Color.WHITE,
                text : policeName,
                pixelOffset : new Cesium.Cartesian2(54.0, -135.0),
                disableDepthTestDistance : 100000000,
                scaleByDistance : new Cesium.NearFarScalar(1000, 1, 20000, 0.2),
                pixelOffsetScaleByDistance : new Cesium.NearFarScalar(1000, 1, 20000, 0.2),
            }
        }));
    }else{
        policePin.position = point;
    }
}
//人员实时监督
function showPolice_3D(realdata,type){
    var url = '';
    $.each(realdata, function(i,val) {
        switch (realdata[i].origin) {
        case '特警':
            url = '../images/pinimg/10.png';
            break;
        case '巡警':
            url = '../images/pinimg/12.png';
            break;
        case '治安警察':
            url = '../images/pinimg/11.png';
            break;
//        case '刑警':    
//            break;    
//        case '边防警察':    
//            break;    
//        case '应急警察':    
//            break;    
//        case '城管':    
//            break;    
        default:
            break;
        }
        var point;
        if(type=='RHPC'){
            point = Cesium.Cartesian3.fromDegrees(Number(this.longitude),Number(this.latitude),Number(this.elevation));
        }else{
            var posArr = this.realPos.split(',');
            point = Cesium.Cartesian3.fromDegrees(Number(posArr[0]),Number(posArr[1]),Number(posArr[2]));
        }
        var puid = this.deviceNum;
        var policeName = this.name;
        var origin = this.origin;
        var clampedpoint = viewer.scene.clampToHeight(point);
        createPolicePin(url,puid,clampedpoint,policeName);
        //如有气泡,更新气泡位置
        var posRealData = realdata[i].realPos.split(',');
        if(document.getElementById("popupDiv"+puid)){
            var cartographic = Cesium.Cartographic.fromCartesian(point);
            var pos = {"lon":Number(posRealData[0]),"lat":Number(posRealData[1]),"alt":Number(cartographic.height)};
            CesiumPop.updatePopPos(viewer,puid,pos,70,260,185,Cesium.Color.WHITE);
        }
    });
    addPOMListener();
}
function deletePolice3DMarks(){
    for(var i = 0; i < police3D_marks.length; i++){
        viewer.entities.remove(police3D_marks[i]); // 将标注从场景移除
    }
    police3D_marks.length = 0;
}