zhitong.yu
2024-10-11 4f58a93c95ff123d51adcb8fa2e521333e8ab022
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<!-- 2017-12-7 14:56:03 | 修改 木遥(微信:  http://marsgis.cn/weixin.html ) -->
<!DOCTYPE html>
<html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<head>
    <!-- 标题及搜索关键字 -->
 
    <link rel="shortcut icon" type="image/x-icon" href="/img/favicon/favicon.ico" />
    <title>历史轨迹</title>
 
    <script type="text/javascript"
            src="/hxzkuwb/Home/demo/lib/include-lib.js"
            libpath="/hxzkuwb/Home/demo/lib/"
            include="jquery,layer,toastr,font-awesome,bootstrap,bootstrap-checkbox,jquery.range,layer,haoutil,mars3d"
    ></script>
 
    <link href="/hxzkuwb/Home/demo/css/style.css" rel="stylesheet" />
    <link rel="stylesheet" href="../../CSS/layui2.css">
    <style>
        ::placeholder{
            color: white;
        }
    </style>
</head>
 
<body class="dark">
<div id="mars3dContainer" class="mars3d-container" style="height: 100%"></div>
 
<div class="infoview" style="margin-top: 1%">
    <div class="layui-form-item" style="text-align: right">
        <label style="">Номер оборудования:</label>
        <div class="" style="display: inline-block">
            <input type="text" style="width: 95%" name="title" id="tagid" required  lay-verify="required" placeholder="Номер или имя" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" style="float: right">
        <label>Время начала:</label>
        <div class="layui-inline" id="start" style=""></div>
    </div>
    <div class="layui-form-item" style="float: right">
        <label>Время окончания:</label>
        <div class="layui-inline" id="end" style=""></div>
    </div>
 
    <div style="text-align: right;margin-right: 2.5%">
        <button type="button" class="layui-btn layui-btn-normal" onclick="StartLocus()">Запрос</button>
        <button type="button" class="layui-btn layui-btn-normal" onclick="StartContinue()">Продолжай.</button>
        <button type="button" class="layui-btn layui-btn-normal" onclick="EndLocus()">Остановить</button>
    </div>
</div>
<script src="/hxzkuwb/Home/demo/js/common.js"></script>
<script src="../../JS/layui.js"></script>
<script src="../../Home/HomeJs/notify.js"></script>
<script src="../../Home/HomeJs/notify_stand.js"></script>
 
<script type="text/javascript">
    "use script"; // 开发环境建议开启严格模式
    window.currentPath = "/example/graphic/custom/fixedRoute/";// 当前示例的目录
    var PinLv = 1000
    var map // mars3d.Map三维地图对象
    var graphicLayer
    var graphicLayerPerson // 矢量图层对象
    // 需要覆盖config.json中地图属性参数(当前示例框架中自动处理合并)
    var mapOptions = {
        scene: {
            center: { lat: 37.791517, lng: 117.418370, alt: 7101, heading: 2, pitch: -26 }
        },
        control: {
            clockAnimate: true, // 时钟动画控制(左下角)
            timeline: true, // 是否显示时间线控件
            compass:false,
            navigationHelpButton:false,
            fullscreenButton:false,
            homeButton:false,
            locationBar:false,
        }
    }
 
    var colors = [
        "rgb(40, 40, 255)",
        "rgb(0, 88, 176)",
        "rgb(0, 128, 255)",
        "rgb(0, 217, 0)",
        "rgb(0, 151, 0)",
        "rgb(255, 199, 83)",
        "rgb(255, 144, 30)",
        "rgb(202, 101, 0)",
        "rgb(255, 0, 0)"
    ]
    /**
     * 初始化地图业务,生命周期钩子函数(必须)
     * 框架在地图初始化完成后自动调用该函数
     * @param {mars3d.Map} mapInstance 地图对象
     * @returns {void} 无
     */
    function onMounted(mapInstance) {
        map = mapInstance // 记录map
        // 创建矢量数据图层
        map.clock.currentTime = Cesium.JulianDate.fromDate(new Date("2024-09-14 10:06:20"))
        map.clock.multiplier = 1
        // 绑定点击事件
        // graphicLayerPerson.on(mars3d.EventType.click, (event) => {
        // })
        // bindLayerContextMenu() // 在图层绑定右键菜单,对所有加到这个图层的矢量数据都生效
        graphicLayerPerson = new mars3d.layer.GraphicLayer()
        map.addLayer(graphicLayerPerson)
        graphicLayerPerson.bindPopup(function (event) {
            var attr = event.graphic?.attr
            if (!attr) {
                return
            }
            return '&nbsp;&nbsp;&nbsp;'+attr
        }, {
            autoClose: false, // 设置为 true 或 false,根据需求
            closeButton:false,
            closeOnClick:false,
            distanceDisplayCondition: false,
 
            pointerEvents:false,
 
        })
    }
 
    /**
     * 释放当前地图业务的生命周期函数
     * @returns {void} 无
     */
    function onUnmounted() {
        map = null
    }
 
    // 在图层绑定Popup弹窗
 
 
 
</script>
<script type="text/javascript">
    "use script" //开发环境建议开启严格模式
 
 
</script>
 
 
<script>
    var start;
    var end;
    var LocusData;
    layui.use('laydate', function() {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#start'
            ,type: 'datetime'
            ,position: 'static'
            ,lang: 'en'
            ,done: function(value, date){
                notify.success(value);
                start = value
            }
        });
        laydate.render({
            elem: '#end'
            ,type: 'datetime'
            ,position: 'static'
            ,lang: 'en'
            ,done: function(value, date){
                notify.success(value);
                end = value
            }
        });
    })
function StartLocus(){
    let tagid = $("#tagid").val();
 
    if (tagid == ""){
        notify.error("Введите номер или имя устройства")
        return false
    }
    if (start == "" || start == undefined){
        notify.error("Выберите время начала")
        return false
    }
    if (end == "" || end == undefined){
        notify.error("Выберите время окончания")
        return false
    }
    notify.success("Загрузите траекторию воспроизведения позже...")
    var data = {
        tagid:tagid,
        start:start,
        end:end
    }
    $.ajax({
        url: "/hxzkuwb/findBaiDuGuiJi",
        data: data,
        async: false,
        success: function (data) {
          LocusData = data //轨迹数据
            Playback(tagid,LocusData[0].name)
        }
    })
 
}
function EndLocus(){
    map.clock.multiplier = 0
    notify.success("Остановить.")
}
function StartContinue(){
    map.clock.multiplier = 1
    notify.success("Продолжай.")
}
 
function Playback(Id,name){
    let modelParam = {
        scale: 50,
        url: "//data.mars3d.cn/gltf/mars/man/walk.gltf",
        pitch:0,
        roll:0,
    };
    let car = new mars3d.graphic.FixedRoute({
        id: Id,
        name:name,
        maxCacheCount: -1,
        model: {
            ...modelParam,
            clampToGround: true,
        },
        attr: name,
        polyline: {
            color: colors[0],
            width: 2,
            clampToGround: true,
        },
    });
    graphicLayerPerson.addGraphic(car);
    car.openPopup()
    graphicLayerPerson.eachGraphic((cars) => {
        // 取出对应车辆的轨迹列表
        var path = LocusData.filter((item) => cars.id === item.tagid);
        if(path.length > 0){
            map.clock.currentTime = Cesium.JulianDate.fromDate(new Date(path[0].addtime))
            var viewPoints = [
                { lng: path[0].gspJingdu, lat:path[0].gpsWeidu }
            ]
            map.setCameraViewList(viewPoints); // 15 为缩放级别,根据需求调整
        }
        // 使用 forEach 确保每个路径点的定时器都有正确的 i 值
        path.forEach((item, index) => {
            setTimeout(() => {
                var point = new mars3d.LngLatPoint(item.gspJingdu, item.gpsWeidu);
                cars.addDynamicPosition(point,item.addtime);
                $("#lblAllLen").text(path[0].name)
                $("#lblAllTime").text(path[0].tagid)
            }, 1);
            if (index == path.length-1){
                notify.success("Загрузка данных завершена")
            }
        });
    });
}
 
</script>
</body>
</html>