-
Notifications
You must be signed in to change notification settings - Fork 0
/
map_new1.html
2606 lines (1902 loc) · 104 KB
/
map_new1.html
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<title>东易物联道路巡车</title>
<!-- <head>
</head> -->
<link rel="stylesheet" href="map.css">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>运输轨迹图</title>
<script type="text/javascript"
src="https://api.map.baidu.com/api?v=2.0&ak=Ok7GZAjC410fYUXKReXKtQaZnKP6Gvde"></script>
<script src="./axios/dist/axios.min.js"></script>
</head>
<body>
<!-- <div class="overlay">
<p>Ctrl按下</p>
</div> -->
<div style="width:100%; height:100vh; border:0px solid gray" id="container">
</div>
<!-- <div>
<button id="saveButton">保存数组到本地</button>
</div> -->
<div class="container">
<table>
<thead>
<tr>
<th>\</th>
<th>车牌</th>
<th>时间</th>
<th>行驶里程</th>
<th>匹配度</th>
</tr>
</thead>
<tbody id="tableBody"></tbody>
</table>
</div>
<!-- 模态框 -->
<div id="myModal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<p id="modalMessage">这是一个自动关闭的提示窗口。</p>
</div>
</div>
<!-- 日期选择 -->
<div class="datepicker-container">
<form>
<label for="datepicker_1">起始日期:</label>
<input type="date" id="datepicker_1">
<br>
<label for="datepicker_2">结束日期:</label>
<input type="date" id="datepicker_2">
</form>
</div>
<!-- 下拉框 -->
<!-- 第一个下拉框 -->
<label for="fruitSelect_1"></label>
<select id="fruitSelect_1" onchange="displaySelectedFruit">
<option value="">线路</option>
<!-- 线路、细分行业、品牌、车型、 -->
</select>
<!-- 第二个下拉框 -->
<label for="fruitSelect_2"></label>
<select id="fruitSelect_2" onchange="displaySelectedFruit">
<option value="">细分行业</option>
</select>
<!-- 第3个下拉框 -->
<label for="fruitSelect_3"></label>
<select id="fruitSelect_3" onchange="displaySelectedFruit">
<option value="">品牌</option>
<!-- 线路、细分行业、品牌、车型、 -->
</select>
<!-- 第4个下拉框 -->
<label for="fruitSelect_4"></label>
<select id="fruitSelect_4" onchange="displaySelectedFruit">
<option value="">车型</option>
</select>
<!-- 第5个下拉框 -->
<label for="fruitSelect_5"></label>
<select id="fruitSelect_5" onchange="displaySelectedFruit">
<option value="">车牌</option>
<!-- 线路、细分行业、品牌、车型、 -->
</select>
<!-- 输入框 -->
<div class="input-container">
<input type="text" class="input-field" id="input" placeholder="">
<label class="input-label" for="input">请输入经纬度,以英文逗号间隔</label>
<button class="input-button" onclick="showInput()">查询</button>
</div>
<!-- 复选框 二选一-->
<div id="choose">
<div class="label-container">
<input type="radio" name="option" id="option1" value="A" checked>
<label for="option1">WGS84</label>
</div>
<div class="label-container">
<input type="radio" name="option" id="option2" value="B">
<label for="option2">Bai Du</label>
</div>
</div>
<button class="mybutton6" onclick="mybutton6_clicked()">确定</button>
<button class="mybutton7" onclick="mybutton7_clicked()">匹配</button>
<script type="text/javascript">
var Data_all = [];//没有处理的经纬度坐标
var classifiedData_all_mysql;
var classifiedData_all;//数据处理后的lng(四层树状结构)——————总分类
// var classifiedData_lng_all;//按照经度四层分类
// var classifiedData_lat_all;//按照纬度四层分类
var classifiedData_uploadtime_all;//按照日期分类————年——月——日
var columnall = {
id: [],
lng: [],
lat: [],
uptime: [],
// address:[]
};
var map; // 保存地图对象
const x_pi = 3.14159265358979324 * 3000.0 / 180.0;
const a = 6378245.0; // 长半轴
const ee = 0.00669342162296594323; // 扁率
var data1_all = []; // 保存地图对象
var tableBody = document.getElementById("tableBody");
function AddtableBody(e,a,b,c,d)
{
// for (var i = 0; i < 10; i++) {
var row = document.createElement("tr");
let id = document.createElement("td");
id.textContent = e;
row.appendChild(id);
var idCell = document.createElement("td");
idCell.textContent = a;
row.appendChild(idCell);
var lngCell = document.createElement("td");
lngCell.textContent = b;
row.appendChild(lngCell);
var latCell = document.createElement("td");
latCell.textContent = c;
row.appendChild(latCell);
var thistime = document.createElement("td");
thistime.textContent = d;
row.appendChild(thistime);
tableBody.appendChild(row);
// }s
}
createMap();
var markerList = [];
// var markerList_shou = [];
// var markerList_auto = [];
var markerList_shouNoinMarkerList = [];
var markerList_autoNoinMarkerList = [];
// 创建按钮元素
var button = document.createElement("button");
button.innerHTML = "保存";
button.id = "myButton";
// 设置按钮样式
button.style.backgroundColor = "rgba(26, 188, 156, 0.8)";
button.style.border = "2px solid green";
button.style.borderRadius = "5px";
button.style.color = "white";
// button.style.padding = "10px 20px";
button.style.textAlign = "center";
button.style.textDecoration = "none";
button.style.display = "inline-block";
button.style.fontSize = "12px";
// button.style.margin = "4px 2px";
button.style.cursor = "pointer";
button.style.position = "absolute";
button.style.top = "100px";
button.style.left = "100px";
button.style.zIndex = "9999";
button.style.width = "40px"; // 设置按钮宽度为120像素
button.style.height = "40px"; // 设置按钮高度为40像素
// 创建第2个按钮元素
var button1 = document.createElement("button");
button1.innerHTML = "打开";
button1.id = "myButton1";
// 设置按钮样式
button1.style.backgroundColor = "rgba(26, 188, 156, 0.8)";
button1.style.border = "2px solid green";
button1.style.borderRadius = "5px";
button1.style.color = "white";
// button1.style.padding = "10px 20px";
button1.style.textAlign = "center";
button1.style.textDecoration = "none";
button1.style.display = "inline-block";
button1.style.fontSize = "12px";
// button1.style.margin = "4px 2px";
button1.style.cursor = "pointer";
button1.style.position = "absolute";
button1.style.top = "140px";
button1.style.left = "100px";
button1.style.zIndex = "9999";
button1.style.width = "40px"; // 设置按钮宽度为120像素
button1.style.height = "40px"; // 设置按钮高度为40像素
// button1.style.backgroundImage = "url('D:/Desktop/image/Draw.png')"; // 替换为你的图片链接
// 创建第一个按钮元素
var button2 = document.createElement("button");
button2.innerHTML = "绘制";
button2.id = "myButton2";
// 设置按钮样式
button2.style.backgroundColor = "rgba(26, 188, 156, 0.8)";
button2.style.border = "2px solid green";
button2.style.borderRadius = "5px";
button2.style.color = "white";
// button1.style.padding = "10px 20px";
button2.style.textAlign = "center";
button2.style.textDecoration = "none";
button2.style.display = "inline-block";
button2.style.fontSize = "12px";
// button1.style.margin = "4px 2px";
button2.style.cursor = "pointer";
button2.style.position = "absolute";
button2.style.top = "180px";
button2.style.left = "100px";
button2.style.zIndex = "9999";
button2.style.width = "40px"; // 设置按钮宽度为120像素
button2.style.height = "40px"; // 设置按钮高度为40像素
// button1.style.backgroundImage = "url('D:/Desktop/image/Draw.png')"; // 替换为你的图片链接
// 创建第一个按钮元素
var button3 = document.createElement("button");
button3.innerHTML = "加载数据";
button3.id = "myButton3";
// 设置按钮样式
button3.style.backgroundColor = "rgba(26, 188, 156, 0.8)";
button3.style.border = "2px solid green";
button3.style.borderRadius = "5px";
button3.style.color = "white";
// button1.style.padding = "10px 20px";
button3.style.textAlign = "center";
button3.style.textDecoration = "none";
button3.style.display = "inline-block";
button3.style.fontSize = "12px";
// button1.style.margin = "4px 2px";
button3.style.cursor = "pointer";
button3.style.position = "absolute";
button3.style.top = "250px";
button3.style.left = "100px";
button3.style.zIndex = "9999";
button3.style.width = "40px"; // 设置按钮宽度为120像素
button3.style.height = "40px"; // 设置按钮高度为40像素
// 创建第一个按钮元素
var button4 = document.createElement("button");
button4.innerHTML = "匹配";
button4.id = "myButton4";
// 设置按钮样式
button4.style.backgroundColor = "rgba(26, 188, 156, 0.8)";
button4.style.border = "2px solid green";
button4.style.borderRadius = "5px";
button4.style.color = "white";
// button1.style.padding = "10px 20px";
button4.style.textAlign = "center";
button4.style.textDecoration = "none";
button4.style.display = "inline-block";
button4.style.fontSize = "12px";
// button1.style.margin = "4px 2px";
button4.style.cursor = "pointer";
button4.style.position = "absolute";
button4.style.top = "320px";
button4.style.left = "100px";
button4.style.zIndex = "9999";
button4.style.width = "40px"; // 设置按钮宽度为120像素
button4.style.height = "40px"; // 设置按钮高度为40像素
// 创建第一个按钮元素
var button5 = document.createElement("button");
button5.innerHTML = "显示道路";
button5.id = "myButton5";
// 设置按钮样式
button5.style.backgroundColor = "rgba(26, 188, 156, 0.8)";
button5.style.border = "2px solid green";
button5.style.borderRadius = "5px";
button5.style.color = "white";
// button1.style.padding = "10px 20px";
button5.style.textAlign = "center";
button5.style.textDecoration = "none";
button5.style.display = "inline-block";
button5.style.fontSize = "12px";
// button1.style.margin = "4px 2px";
button5.style.cursor = "pointer";
button5.style.position = "absolute";
button5.style.top = "390px";
button5.style.left = "100px";
button5.style.zIndex = "9999";
button5.style.width = "40px"; // 设置按钮宽度为120像素
button5.style.height = "40px"; // 设置按钮高度为40像素
//-----------------------button保存
// 添加按钮按下效果的样式
button.addEventListener("mousedown", function () {
button.style.backgroundColor = "rgba(26, 188, 156, 0.3)";
});
button.addEventListener("mouseup", function () {
button.style.backgroundColor = "rgba(26, 188, 156, 0.8)";
// var markerList =DrawRoute_new();
// 转换数组为字符串
var markerList_save = [];
for (var i = 0; i < markerList.length; i++) {
markerList_save.push(markerList[i].point.lng + ',' + markerList[i].point.lat);
}
markerList_save.push('flag1_start');
// 将markerList_shouNoinMarkerList数组存储到markerList_save数组中
for (var i = 0; i < markerList_shouNoinMarkerList.length; i++) {
markerList_save.push(markerList_shouNoinMarkerList[i]);
}
markerList_save.push('flag1_end');
markerList_save.push('flag2_start');
for (var i = 0; i < markerList_autoNoinMarkerList.length; i++) {
markerList_save.push(markerList_autoNoinMarkerList[i]);
}
markerList_save.push('flag2_end');
var arrayString = markerList_save.join('\n');
// 创建一个输入框用于输入文件名
var fileName = prompt("请输入文件名");
if (fileName) {
// 创建一个 Blob 对象
var blob = new Blob([arrayString], { type: 'text/plain' });
// 创建一个 <a> 元素
var link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = fileName + '.txt';
// 模拟点击下载链接
link.click();
}
});
//-----------------------button1打开
// 添加按钮按下效果的样式
button1.addEventListener("mousedown", function () {
button1.style.backgroundColor = "rgba(26, 188, 156, 0.3)";
});
button1.addEventListener("mouseup", function () {
button1.style.backgroundColor = "rgba(26, 188, 156, 0.8)";
const fileInput = document.createElement('input');
fileInput.type = 'file';
fileInput.id = 'fileInput';
fileInput.addEventListener('change', (event) => {
const file = event.target.files[0];
const reader = new FileReader();
reader.onload = function (e) {
const fileContent = e.target.result;
// console.log(fileContent);
// 按照换行符将字符串拆分成多个行
const lines = fileContent.split('\n');
// 创建数组存储结果
const coordinates = [];
let flag1 = [];
let flag2 = [];
// 遍历每一行
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
// 使用逗号将每一行拆分成坐标对或标记
const coords = line.split(',');
// 判断是否为标记行
if (coords.length === 1) {
if (line === 'flag1_start') {
for (let j = i + 1; j < lines.length; j++) {
if (lines[j] != 'flag1_end') {
flag1.push(lines[j]);
} else {
break; // 结束循环
}
}
} else if (line === 'flag2_start') {
for (let j = i + 1; j < lines.length; j++) {
if (lines[j] != 'flag2_end') {
flag2.push(lines[j]);
} else {
break; // 结束循环
}
}
}
} else {
const lng = parseFloat(coords[0]);
const lat = parseFloat(coords[1]);
// 将坐标对存入数组
coordinates.push({ lng, lat });
}
}
// console.log(flag1);console.log(flag2);
for (var i = 0; i < flag1.length; i++) {
var startPoint_shou = new BMap.Point(coordinates[flag1[i] - 1].lng, coordinates[flag1[i] - 1].lat);
var endPoint_shou = new BMap.Point(coordinates[flag1[i]].lng, coordinates[flag1[i]].lat);
DrawRoute([startPoint_shou, endPoint_shou]);
// console.log(flag1[i]);
}
//flag2是自动
for (var i = 0; i < flag2.length; i++) {
var start = new BMap.Point(coordinates[flag2[i] - 1].lng, coordinates[flag2[i] - 1].lat);
var end = new BMap.Point(coordinates[flag2[i]].lng, coordinates[flag2[i]].lat);
// console.log(flag2[i]);
// console.log(start);
getNavigationPoints(start, end);
}
};
reader.readAsText(file);
});
fileInput.click();
});
// 添加按钮状态变量
//-----------------------button2绘制
var isButtonOn2 = false;
var toggleClickListener = DrawRoute_new();
// 添加按钮点击事件
button2.addEventListener("click", function () {
isButtonOn2 = !isButtonOn2;
updateButtonStyle2();
});
// 更新按钮样式函数
function updateButtonStyle2() {
if (isButtonOn2) {
button2.style.backgroundColor = "rgba(26, 188, 156, 0.3)";
toggleClickListener(true); // 启用绘制功能
} else {
button2.style.backgroundColor = "rgba(26, 188, 156, 0.8)";
toggleClickListener(false); // 禁用绘制功能
}
}
//-----------------------button3数据库
// 添加按钮按下效果的样式
button3.addEventListener("mousedown", function () {
button3.style.backgroundColor = "rgba(26, 188, 156, 0.3)";
});
button3.addEventListener("mouseup", function () {
button3.style.backgroundColor = "rgba(26, 188, 156, 0.8)";
const fileInput = document.createElement('input');
fileInput.type = 'file';
fileInput.id = 'fileInput';
fileInput.addEventListener('change', (event) => {
const file = event.target.files[0];
const reader = new FileReader();
Show_Tips("数据库处理中,请稍后");
reader.onload = function (e) {
const fileContent = e.target.result;
// console.log(fileContent);
// console.log(fileContent.length);
// 假设你已经将文件内容存储在变量 fileContent 中
const lines = fileContent.split('\n'); // 将文件内容按换行符分割成数组
const column1 = [];
const column2 = [];
const column3 = [];
const column4 = [];
//const column5 = [];
for (let i = 2; i < lines.length - 2; i++) {
const columns = lines[i].split('\t'); // 将每行数据按制表符分割成数组
column1.push(columns[0]);//id
column2.push(columns[1]);//lng
column3.push(columns[2]);//lat
column4.push(columns[3]);//uploadtime
//column5.push(columns[4]);//address
}
columnall.id = column1;
// columnall.lng=column2;
// columnall.lat=column3;
columnall.uploadtime = column4;
// columnall.address=column5;
for (let i = 0; i < column2.length; i++) {
columnall.lng.push(transform(column2[i], column3[i]).bdLon);//经度
columnall.lat.push(transform(column2[i], column3[i]).bdLat);//纬度
}
Data_all = columnall.lng.map((item, index) => new BMap.Point(item, columnall.lat[index]));
classifiedData_all = classifyData_all(columnall);
//classifiedData_lng_all= classifyData(columnall.lng);
//classifiedData_lat_all=classifyData(columnall.lat);
//classifiedData_uploadtime_all=classifyDateTime(columnall.uploadtime);
//console.log(classifiedData_all);
// console.log(classifiedData_all[97.4][97.49][97.494][97.4944].length);
Show_Tips("数据处理完毕", 1000);
};
reader.readAsText(file);
});
fileInput.click();
});
//-----------------------button4测试
// 添加按钮按下效果的样式
button4.addEventListener("mousedown", function () {
button4.style.backgroundColor = "rgba(26, 188, 156, 0.3)";
});
button4.addEventListener("mouseup", function () {
button4.style.backgroundColor = "rgba(26, 188, 156, 0.8)";
var thisstr = [];
var ishavedate = 0;
// 调用导航服务
var driving = new BMap.DrivingRoute(map, { // 创建一个驾车导航实例
//renderOptions: { map: map }, // 设置渲染选项,将导航结果显示在地图上
onSearchComplete: function (results) { // 定义导航完成时的回调函数
if (driving.getStatus() === BMAP_STATUS_SUCCESS) { // 判断导航状态是否成功
var plan = results.getPlan(0); // 获取导航方案
var route = plan.getRoute(0); // 获取导航路线
var path = route.getPath(); // 获取导航路线上的所有道路点
//输出导航路线上的道路点信息
// console.log( path.length);
for (var i = 1; i < path.length; i++) {//两点之间所有导航点,i=1 是因为有起始点
var point_previous = path[i - 1];
var point = path[i];
// console.log(path.length+"道路点:" + path[i].lng + "," + path[i].lat);
// AddMark(path[i].lng,path[i].lat);
var point_divide = []; var Now_Point_Class = [];
var CenterPoint_11 = new BMap.Point(point_previous.lng, point_previous.lat);
var CenterPoint_12 = new BMap.Point(point.lng, point.lat);
var dlng = point.lng - point_previous.lng;
var dlat = point.lat - point_previous.lat;
var Difference = Math.sqrt(dlng * dlng + dlat * dlat);
var Point_Time = Math.ceil(Difference / 0.0001);//分成多少段
// var Point_Distance=(Difference/Point_Time);//每一段的长度
for (var j = 1; j < Point_Time + 1; j++) {//每个导航点之间分的点,间隔0.0001
var Now_Point = new BMap.Point(point_previous.lng + j * dlng / Point_Time, point_previous.lat + j * dlat / Point_Time);//当前点
point_divide.push(Now_Point);//每个点放入到数组
//console.log(Now_Point);
var Now_Point_Class_center = new BMap.Point(Math.floor(point_divide[j - 1].lng * 10000) / 10000, Math.floor(point_divide[j - 1].lat * 10000) / 10000);//中心点所在组类
// console.log(Now_Point_Class_center);
var Now_Point_Class_1 = new BMap.Point((Math.floor(point_divide[j - 1].lng * 10000) / 10000 - 0.0001).toFixed(4), (Math.floor(point_divide[j - 1].lat * 10000) / 10000 + 0.0001).toFixed(4));
var Now_Point_Class_2 = new BMap.Point((Math.floor(point_divide[j - 1].lng * 10000) / 10000).toFixed(4), (Math.floor(point_divide[j - 1].lat * 10000) / 10000 + 0.0001).toFixed(4));
var Now_Point_Class_3 = new BMap.Point((Math.floor(point_divide[j - 1].lng * 10000) / 10000 + 0.0001).toFixed(4), (Math.floor(point_divide[j - 1].lat * 10000) / 10000 + 0.0001).toFixed(4));
var Now_Point_Class_4 = new BMap.Point((Math.floor(point_divide[j - 1].lng * 10000) / 10000 - 0.0001).toFixed(4), (Math.floor(point_divide[j - 1].lat * 10000) / 10000).toFixed(4));
var Now_Point_Class_5 = new BMap.Point((Math.floor(point_divide[j - 1].lng * 10000) / 10000).toFixed(4), (Math.floor(point_divide[j - 1].lat * 10000) / 10000).toFixed(4));
var Now_Point_Class_6 = new BMap.Point((Math.floor(point_divide[j - 1].lng * 10000) / 10000 + 0.0001).toFixed(4), (Math.floor(point_divide[j - 1].lat * 10000) / 10000).toFixed(4));
var Now_Point_Class_7 = new BMap.Point((Math.floor(point_divide[j - 1].lng * 10000) / 10000 - 0.0001).toFixed(4), (Math.floor(point_divide[j - 1].lat * 10000) / 10000 - 0.0001).toFixed(4));
var Now_Point_Class_8 = new BMap.Point((Math.floor(point_divide[j - 1].lng * 10000) / 10000).toFixed(4), (Math.floor(point_divide[j - 1].lat * 10000) / 10000 - 0.0001).toFixed(4));
var Now_Point_Class_9 = new BMap.Point((Math.floor(point_divide[j - 1].lng * 10000) / 10000 + 0.0001).toFixed(4), (Math.floor(point_divide[j - 1].lat * 10000) / 10000 - 0.0001).toFixed(4));
Now_Point_Class.push(Now_Point_Class_1, Now_Point_Class_2, Now_Point_Class_3, Now_Point_Class_4, Now_Point_Class_5, Now_Point_Class_6, Now_Point_Class_7, Now_Point_Class_8, Now_Point_Class_9);
}
let Now_Point_Class_DeleteRepetPoint = removeDuplicatePoints(Now_Point_Class);//剔除重复方格后的新数组(两个导航点之间的所有方格中心点)
// console.log(Now_Point_Class_DeleteRepetPoint);
// for(var ni=0;ni<Now_Point_Class_DeleteRepetPoint.length;ni++)
// {
// AddMark(Now_Point_Class_DeleteRepetPoint[ni].lng,Now_Point_Class_DeleteRepetPoint[ni].lat);
// }
for (var k = 0; k < Now_Point_Class_DeleteRepetPoint.length; k++) {//将数组遍历一遍找到是否在数据库有这个数组,然后返回这个数据库点的信息。
var item = new BMap.Point(Now_Point_Class_DeleteRepetPoint[k].lng, Now_Point_Class_DeleteRepetPoint[k].lat)
// console.log(item);
var key1 = new BMap.Point(Math.floor(item.lng * 10) / 10, Math.floor(item.lat * 10) / 10);
var key2 = new BMap.Point(Math.floor(item.lng * 100) / 100, Math.floor(item.lat * 100) / 100);
var key3 = new BMap.Point(Math.floor(item.lng * 1000) / 1000, Math.floor(item.lat * 1000) / 1000);
var key4 = new BMap.Point(Math.floor(item.lng * 10000) / 10000, Math.floor(item.lat * 10000) / 10000);
// console.log(key1.lat,key2.lat,key3.lat,key4.lat); //不能索引界外数组。
// console.log(Array.isArray(classifiedData_lng_all)); //不能索引界外数组。
if (
classifiedData_all[key1.lng] && // 判断第一维索引是否存在
classifiedData_all[key1.lng][key2.lng] && // 判断第二维索引是否存在
classifiedData_all[key1.lng][key2.lng][key3.lng] && // 判断第三维索引是否存在
classifiedData_all[key1.lng][key2.lng][key3.lng][key4.lng] // 判断第四维索引是否存在
) {
for (let t = 0; t < classifiedData_all[key1.lng][key2.lng][key3.lng][key4.lng].length; t++) {
let current_lat = Math.floor((classifiedData_all[key1.lng][key2.lng][key3.lng][key4.lng][t].lat) * 10000) / 10000;
if (current_lat == Now_Point_Class_DeleteRepetPoint[k].lat) {
ishavedate = 1;
if ((startDate_year === undefined && endDate_year === undefined) || (startDate_year == 0 && endDate_year == 0)) {
thisstr.push(classifiedData_all[key1.lng][key2.lng][key3.lng][key4.lng][t]);
// console.log(classifiedData_all[key1.lng][key2.lng][key3.lng][key4.lng][t]);
AddMark_inputcontainer1(classifiedData_all[key1.lng][key2.lng][key3.lng][key4.lng][t].lng, classifiedData_all[key1.lng][key2.lng][key3.lng][key4.lng][t].lat);
} else {
//筛选框:
// 使用 split 方法拆分日期和时间部分
const [datePart, timePart] = (classifiedData_all[key1.lng][key2.lng][key3.lng][key4.lng][t].uploadtime).split(' ');
// 拆分日期部分为年、月、日
const [year, month, day] = datePart.split('/').map(Number);
// console.log(year, month, day);
if (isWithinRange(year, month, day, startDate_year, startDate_month, startDate_day, endDate_year, endDate_month, endDate_day)) {
console.log(classifiedData_all[key1.lng][key2.lng][key3.lng][key4.lng][t]);
}
}
}
}
}
}
}
}
console.log(removeDuplicate(thisstr));
if (ishavedate == 0) Show_Tips("无满足数据", 600);
}
});
//输出手动导航点的经纬度
for (var i = 0; i < markerList_autoNoinMarkerList.length; i++) {
var startPoint = new BMap.Point(markerList[markerList_autoNoinMarkerList[i] - 1].point.lng, markerList[markerList_autoNoinMarkerList[i] - 1].point.lat);
var endPoint = new BMap.Point(markerList[markerList_autoNoinMarkerList[i]].point.lng, markerList[markerList_autoNoinMarkerList[i]].point.lat);
// 开始导航
driving.search(startPoint, endPoint); // 开始进行起点到终点的导航
}
for (var i = 0; i < markerList_shouNoinMarkerList.length; i++) {
var startPoint_shou = new BMap.Point(markerList[markerList_shouNoinMarkerList[i] - 1].point.lng, markerList[markerList_shouNoinMarkerList[i] - 1].point.lat);
var endPoint_shou = new BMap.Point(markerList[markerList_shouNoinMarkerList[i]].point.lng, markerList[markerList_shouNoinMarkerList[i]].point.lat);
// console.log(startPoint_shou, endPoint_shou);
}
//剔除数组重复元素,返会新数组——————————————————————————start
function comparePoints(point1, point2) {
return point1.lng === point2.lng && point1.lat === point2.lat;
}
function removeDuplicatePoints(arr) {
let uniqueArr = [];
for (let i = 0; i < arr.length; i++) {
let isDuplicate = false;
for (let j = i + 1; j < arr.length; j++) {
if (comparePoints(arr[i], arr[j])) {
isDuplicate = true;
break;
}
}
if (!isDuplicate) {
uniqueArr.push(arr[i]);
}
}
return uniqueArr;
}
function removeDuplicate(data) {
let uniqueIds = {}; // 用对象来存储唯一的id
let newData = [];
for (let i = 0; i < data.length; i++) {
let id = data[i].id;
if (!uniqueIds[id]) { // 如果id不在对象中,则说明是第一次出现,可以加入新数组
uniqueIds[id] = true;
newData.push(data[i]);
}
}
return newData;
}
//剔除数组重复元素,返会新数组_________________________end
});
//----------------button5
button5.addEventListener("mousedown", function () {
button5.style.backgroundColor = "rgba(26, 188, 156, 0.3)";
});
button5.addEventListener("mouseup", function () {
button5.style.backgroundColor = "rgba(26, 188, 156, 0.8)";
const Arr = Data_all.slice(100000, 500000);
const newArr = Arr.filter((_, index) => index % 100 === 0);
map.setViewport(newArr);//视角内包括所有线路
DrawRoute(newArr);
});
// $(function() {
// var page = 1; // 起始页码
// var pageSize = 10000; // 每页记录数
// function fetchData() {
// $.ajax({
// url: "http://localhost:8077/myindex.php",
// type: 'get',
// dataType: 'json',
// data: {
// page: page
// },
// success: function(data) {
// var html = '';
// for (var i = 0; i < data.length; i++) {
// html += '<tr>'
// + '<td>' + data[i].id + '</td>'
// + '<td>' + data[i].lng + '</td>'
// + '<td>' + data[i].lat + '</td>'
// + '</tr>';
// }
// // $('#data').append(html);
// data1_all.push(data);
// if (data.length === pageSize) {
// // 继续请求下一页数据
// page++;
// fetchData();
// }
// },
// error: function(xhr, status, error) {
// console.log(error);
// }
// });
// }
// fetchData();
// });
// console.log(data1_all);
// document.addEventListener("DOMContentLoaded", function() {
// // 添加滚轮事件监听器
// window.addEventListener("wheel", handleWheelEvent);
// function handleWheelEvent(event) {
// event.preventDefault();
// const deltaY = event.deltaY;
// if (deltaY > 0) {
// // 向下滚动
// // 执行相应操作
// console.log("向下滚动");
// console.log( map.getZoom());
// } else if (deltaY < 0) {
// // 向上滚动
// // 执行相应操作
// console.log("向上滚动");
// console.log( map.getZoom());
// }
// }
// });
function mybutton6_clicked() {
//var License_all = ["鄂c9v670", "鄂c9v925", "新a34554", "新a34641", "新a34644", "豫rdg697", "豫rkk595", "豫rpc537", "豫rx2585"];
var License_all = ["鄂c9v925", "新a34554", "新a34641", "新a34644", "豫rkk595", "豫rx2585"];
// var License_all = ["鄂c9v670"];//109页
// var License_all = [ "豫rpc537"];//95页
// var License_all = [ "豫rdg697"];//176页
//var License_all = [ "豫rx2585"];//有问题
let currentLicenseIndex = 0;
function fetchDataForLicense(license) {
const batchSize = 100000;
let offset = 0;
var thisstr = [];
var ishavedate = 0;
function fetchData() {
axios.post("./myindex.php", {
License: license,
offset: offset,
limit: batchSize
})
.then(response => {
const data = response.data;
if (data.length > 0) {
var thispoint = data.map(function (item) {
if(item.lng<116){
var lng = transform(item.lng, item.lat).bdLon; // 获取当前元素的 lng 值
var lat = transform(item.lng, item.lat).bdLat; // 获取当前元素的 lat 值
columnall.uptime.push(item.uptime);
columnall.id.push(item.id);
columnall.lng.push(lng);
columnall.lat.push(lat);
}
return new BMap.Point(lng, lat); // 返回 BMap.Point 对象
});
//杂点错点剔除算法,两者之差初步为1
// classifiedData_all_mysql = classifyData_all(columnall);
var points = [];
for (var i = 0; i < columnall.lng.length; i += 10) {
var point = new BMap.Point(columnall.lng[i], columnall.lat[i]);
points.push(point);
}
//console.log(points);
// map.setViewport(newArr);//视角内包括所有线路
DrawRoute_DiffrenteColor(points, currentLicenseIndex);
// 绘图函数END
// 递归调用
offset += batchSize;
fetchData();
columnall = {
id: [],
lng: [],
lat: [],
uptime: [],
};
}
else {