DataMap.html 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  1. <!DOCTYPE html>
  2. <html class="x-admin-sm">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="renderer" content="webkit">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <meta name="viewport"
  8. content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
  9. <link rel="shortcut icon" href="https://osscold.baozhida.cn/favicon.ico">
  10. <link rel="bookmark" href="https://osscold.baozhida.cn/favicon.ico">
  11. <link rel="stylesheet" href="https://osscold.baozhida.cn/css/font.css">
  12. <link rel="stylesheet" href="https://osscold.baozhida.cn/css/xadmin.css">
  13. <script src="https://osscold.baozhida.cn/js/jquery.min.js"></script>
  14. <script src="https://osscold.baozhida.cn/js/jquery.cookie.min.js"></script>
  15. <script src="https://osscold.baozhida.cn/lib/layui/layui.js" charset="utf-8"></script>
  16. <script src="https://osscold.baozhida.cn/js/echarts.js" charset="utf-8"></script>
  17. <script type="text/javascript" src="https://osscold.baozhida.cn/js/xadmin.js"></script>
  18. <style>
  19. .nav_mine {
  20. height: 40px;
  21. display: flex;
  22. align-items: center;
  23. overflow-y: hidden;
  24. overflow-x: hidden;
  25. flex-wrap: nowrap;
  26. white-space:nowrap;
  27. }
  28. </style>
  29. </head>
  30. <body>
  31. <div class="x-nav">
  32. <span class="layui-breadcrumb">
  33. <a href="">首页</a>
  34. <a><cite>宝智达</cite></a>
  35. </span>
  36. <a class="layui-btn layui-btn-normal" style="line-height:1.6em;margin-top:3px;float:right"
  37. onclick="location.reload()" title="刷新">
  38. <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
  39. </a>
  40. </div>
  41. <div class="layui-fluid">
  42. <div class="layui-row">
  43. <!-- // 传感器 选择-->
  44. <div class="layui-col-md4">
  45. <div class="layui-card">
  46. <div class="layui-card-body ">
  47. <form class="layui-form layui-col-space5" οnsubmit="return false;">
  48. <div class="layui-input-inline layui-show-xs-block">
  49. <input value="" type="text" id="D_T_sn" name="D_T_sn" placeholder="请输入 SN"
  50. autocomplete="off"
  51. class="layui-input"></div>
  52. <div class="layui-input-inline layui-show-xs-block">
  53. <input value="" type="text" id="D_Name" name="D_Name" placeholder="请输入 传感器名称"
  54. autocomplete="off"
  55. class="layui-input"></div>
  56. <div class="layui-input-inline layui-show-xs-block">
  57. <select id="Class_1" name="Class_1">
  58. <option value=0>所有分类</option>
  59. {{range $index, $elem := .Class_List}}
  60. <option value={{$elem.Id}}>{{$elem.T_name}}
  61. </option>
  62. {{end}}
  63. </select>
  64. </div>
  65. <div class="layui-input-inline layui-show-xs-block">
  66. <div class="layui-btn layui-btn-normal"
  67. onclick="get_DeviceSensor_list(0)">
  68. <i class="layui-icon">&#xe615;</i></div>
  69. </div>
  70. </form>
  71. <hr>
  72. </div>
  73. <div class="layui-card-body " style="margin-top: -20px">
  74. <div id="DeviceSensor_list" style="width: 98%; overflow: hidden;">
  75. <div style="color: #1E9FFF;text-align: center;font-size: 15px;margin-top: 150px">加载中...</div>
  76. <!-- <div class="layui-col"-->
  77. <!-- style="height: 52px;background-color: #fafafa;border-radius:5px;padding-top: 2px;">-->
  78. <!-- <img style="float: left;width: 50px;margin: 0px 10px" src="https://osscold.baozhida.cn/images/温湿度传感器-1.png"-->
  79. <!-- height="50"-->
  80. <!-- width="40"/>-->
  81. <!-- <div style="float: left;">-->
  82. <!-- <div style="margin-top: 4px;font-size: 14px">士大夫撒地方递四方速递</div>-->
  83. <!-- <div style="margin-top: -3px;font-size: 12px">SN:KF20210510143443 [1]</div>-->
  84. <!-- </div>-->
  85. <!-- <div class="layui-card-header"-->
  86. <!-- style="float: right;padding-left: 0px;padding-top: 6px;color: #1E9FFF">-->
  87. <!-- 》-->
  88. <!-- </div>-->
  89. <!-- </div>-->
  90. </div>
  91. </div>
  92. <div class="layui-card-body ">
  93. <div style="height: 70px">
  94. <div class="layui-card-body ">
  95. <div class="page">
  96. <div id="DeviceSensor_list_Pages">
  97. <!-- <a class="prev" href="">&lt;&lt;</a>-->
  98. <!-- <a class="num" href="">1222</a>-->
  99. <!-- <span class="current">111</span>-->
  100. <!-- <a class="num" href="">444</a>-->
  101. <!-- <a class="next" href="">&gt;&gt;</a>-->
  102. </div>
  103. </div>
  104. <div style="color: #1E9FFF;text-align: center" id="DeviceSensor_list_Pages_x"></div>
  105. </div>
  106. </div>
  107. </div>
  108. </div>
  109. </div>
  110. <!-- // 传感器 选择-->
  111. <div class="layui-col-md8">
  112. <div class="layui-card">
  113. <div class="layui-card-body ">
  114. <form class="layui-form layui-col-space5" οnsubmit="return false;">
  115. <div class="layui-input-inline layui-show-xs-block">
  116. 历史任务查询:
  117. </div>
  118. <div class="layui-input-inline layui-show-xs-block">
  119. <div class="layui-btn layui-btn-normal"
  120. onclick="quick_1()">
  121. <i class="layui-icon">今天</i>
  122. </div>
  123. </div>
  124. <div class="layui-input-inline layui-show-xs-block">
  125. <div class="layui-btn layui-btn-normal"
  126. onclick="quick_2()">
  127. <i class="layui-icon">近一周</i>
  128. </div>
  129. </div>
  130. <div class="layui-input-inline layui-show-xs-block">
  131. <div class="layui-btn layui-btn-normal"
  132. onclick="quick_3()">
  133. <i class="layui-icon">近两周</i>
  134. </div>
  135. </div>
  136. <!-- <div class="layui-input-inline layui-show-xs-block">-->
  137. <!-- <div class="layui-btn layui-btn-normal"-->
  138. <!-- onclick="quick_4()">-->
  139. <!-- <i class="layui-icon">近一季度</i>-->
  140. <!-- </div>-->
  141. <!-- </div>-->
  142. <div style="float: right">
  143. <div class="layui-input-inline layui-show-xs-block">
  144. 自定义时间查询:
  145. </div>
  146. <div class="layui-inline layui-show-xs-block">
  147. <input class="layui-input" autocomplete="off" placeholder="开始日" name="Time_start" id="Time_start" lay-key="1"></div>
  148. <div class="layui-inline layui-show-xs-block">
  149. <input class="layui-input" autocomplete="off" placeholder="截止日" name="Time_end" id="Time_end" lay-key="2"></div>
  150. <div class="layui-input-inline layui-show-xs-block">
  151. <div class="layui-btn layui-btn-normal"
  152. onclick="on_get_DeviceSensor_data()">
  153. <i class="layui-icon">&#xe615;</i>
  154. </div>
  155. </div>
  156. </div>
  157. </form>
  158. <hr>
  159. <div id="DeviceTask_List" class="nav_mine">
  160. <div class="layui-btn" style="height: 60px;padding-top: 8px">
  161. <div style="height: 15px;">2022-5-11 00:00:00</div>
  162. <div style="height: 15px;">2022-5-11 23:59:59</div>
  163. </div>
  164. <button type="button" class="layui-btn layui-btn-xs">一个标准的按钮</button>
  165. </div>
  166. <script>
  167. let container = document.querySelector(".nav_mine");
  168. container.addEventListener("wheel", (event) => {
  169. event.preventDefault();
  170. container.scrollLeft += event.deltaY;
  171. })
  172. </script>
  173. <hr>
  174. </div>
  175. <div class="layui-card-body " >
  176. <div id="container" style="width: 100%;height:735px;"></div>
  177. </div>
  178. </div>
  179. </div>
  180. </div>
  181. </div>
  182. </div>
  183. </body>
  184. <script>
  185. //获取GET
  186. function getPar(par) {
  187. //获取当前URL
  188. var local_url = document.location.href;
  189. //获取要取得的get参数位置
  190. var get = local_url.indexOf(par + "=")
  191. ;
  192. if (get == -1) {
  193. return false;
  194. }
  195. //截取字符串
  196. //截取字符串
  197. var get_par = local_url.slice(par.length + get + 1);
  198. //判断截取后的字符串是否还有其他get参数
  199. var nextPar = get_par.indexOf("&")
  200. ;
  201. if (nextPar != -1) {
  202. get_par = get_par.slice(0, nextPar);
  203. }
  204. return get_par;
  205. }
  206. layui.use(['laydate', 'form'],
  207. function () {
  208. var laydate = layui.laydate;
  209. //执行一个laydate实例
  210. laydate.render({
  211. elem: '#Time_start' //指定元素
  212. ,type: 'datetime'
  213. });
  214. //执行一个laydate实例
  215. laydate.render({
  216. elem: '#Time_end' //指定元素
  217. ,type: 'datetime'
  218. });
  219. });
  220. var T_name = ""
  221. var T_sn = ""
  222. var T_class_id = 0
  223. var Admin_rh = "{{$.Admin_r.Admin_rh}}"
  224. var T_id = 0
  225. var T_sn_T_id = ""
  226. var Time_start = ""
  227. var Time_end = ""
  228. var DeviceSensor_lite = []
  229. var DeviceSensor_data = []
  230. /// --------------- 传感器列表
  231. // 页面 加载完成后执行
  232. window.onload = function () {
  233. console.log("页面 加载完成后执行")
  234. quick_1()
  235. get_DeviceSensor_list(0)
  236. // var map = new AMap.Map('container', {
  237. // resizeEnable: true, //是否监控地图容器尺寸变化
  238. // zoom:11, //初始化地图层级
  239. // center: [116.397428, 39.90923] //初始化地图中心点
  240. // });
  241. }
  242. function ChangeDiv(e) {
  243. var divs = document.getElementsByClassName("ChangeDiv");
  244. var len = divs.length;
  245. for(var i=0;i<len;i++){
  246. divs[i].style.border = "1px solid #ffffff";
  247. }
  248. e.style.border = "1px solid #ed0000";
  249. }
  250. // 今天
  251. function quick_1() {
  252. var myDate = new Date();
  253. y = myDate.getFullYear(); //获取当前年份(2位)
  254. m = myDate.getMonth()+1; //获取当前月份(0-11,0代表1月)
  255. d = myDate.getDate(); //获取当前日(1-31)
  256. console.log(y+"-"+m+"-"+d)
  257. Time_start = y+"-"+m+"-"+d + " 00:00:00"
  258. Time_end = y+"-"+m+"-"+d + " 23:59:59"
  259. $("#Time_start").val(Time_start)
  260. $("#Time_end").val(Time_end)
  261. f_DeviceTask_List()
  262. }
  263. // 近一周
  264. function quick_2() {
  265. var myDate = new Date();
  266. y = myDate.getFullYear(); //获取当前年份(2位)
  267. m = myDate.getMonth()+1; //获取当前月份(0-11,0代表1月)
  268. d = myDate.getDate(); //获取当前日(1-31)
  269. console.log(y+"-"+m+"-"+d)
  270. Time_end = y+"-"+m+"-"+d + " 23:59:59"
  271. $("#Time_end").val(Time_end)
  272. myDate=myDate.setDate(myDate.getDate() - 7);
  273. myDate=new Date(myDate);
  274. y = myDate.getFullYear(); //获取当前年份(2位)
  275. m = myDate.getMonth()+1; //获取当前月份(0-11,0代表1月)
  276. d = myDate.getDate(); //获取当前日(1-31)
  277. Time_start = y+"-"+m+"-"+d + " 00:00:00"
  278. $("#Time_start").val(Time_start)
  279. f_DeviceTask_List()
  280. }
  281. // 近一月
  282. function quick_3() {
  283. var myDate = new Date();
  284. y = myDate.getFullYear(); //获取当前年份(2位)
  285. m = myDate.getMonth()+1; //获取当前月份(0-11,0代表1月)
  286. d = myDate.getDate(); //获取当前日(1-31)
  287. console.log(y+"-"+m+"-"+d)
  288. Time_end = y+"-"+m+"-"+d + " 23:59:59"
  289. $("#Time_end").val(Time_end)
  290. myDate=myDate.setDate(myDate.getDate() - 14);
  291. myDate=new Date(myDate);
  292. y = myDate.getFullYear(); //获取当前年份(2位)
  293. m = myDate.getMonth()+1; //获取当前月份(0-11,0代表1月)
  294. d = myDate.getDate(); //获取当前日(1-31)
  295. Time_start = y+"-"+m+"-"+d + " 00:00:00"
  296. $("#Time_start").val(Time_start)
  297. f_DeviceTask_List()
  298. }
  299. // 近一季度
  300. function quick_4() {
  301. var myDate = new Date();
  302. y = myDate.getFullYear(); //获取当前年份(2位)
  303. m = myDate.getMonth()+1; //获取当前月份(0-11,0代表1月)
  304. d = myDate.getDate(); //获取当前日(1-31)
  305. console.log(y+"-"+m+"-"+d)
  306. Time_end = y+"-"+m+"-"+d + " 23:59:59"
  307. $("#Time_end").val(Time_end)
  308. myDate=myDate.setDate(myDate.getDate() - 30 * 3);
  309. myDate=new Date(myDate);
  310. y = myDate.getFullYear(); //获取当前年份(2位)
  311. m = myDate.getMonth()+1; //获取当前月份(0-11,0代表1月)
  312. d = myDate.getDate(); //获取当前日(1-31)
  313. Time_start = y+"-"+m+"-"+d + " 00:00:00"
  314. $("#Time_start").val(Time_start)
  315. f_DeviceTask_List()
  316. }
  317. // 获取任务列表
  318. function f_DeviceTask_List() {
  319. $('#DeviceTask_List').html("")
  320. $.ajax({
  321. type: 'POST',
  322. url: '../../Device/DeviceTask_List',//发送请求
  323. data: {
  324. T_sn:T_sn_T_id,
  325. Time_start: $("#Time_start").val().replace("+", ' ') ,
  326. Time_end: $("#Time_end").val().replace("+", ' '),
  327. },
  328. success: function (result) {
  329. console.log(result)
  330. if(result.Data.length == 0){
  331. layer.msg('时间段内 没有找到任务!',{time: 500});
  332. }
  333. if(result.Data.length > 10){
  334. layer.msg('只能显示 时间段 10次任务!');
  335. }
  336. Add_DeviceTask_List(result.Data)
  337. }
  338. });
  339. }
  340. T_Ut_start = ""
  341. T_Ut_end = ""
  342. function Add_DeviceTask_List(DS_lite) {
  343. for (let i = 0; i < DS_lite.length; i++) {
  344. if(i >= 10){
  345. return
  346. }
  347. T_Ut_start = dateChangeFormat('YYYY-mm-dd HH:MM:SS', DS_lite[i].T_Ut_start)
  348. T_Ut_end = dateChangeFormat('YYYY-mm-dd HH:MM:SS', DS_lite[i].T_Ut_end)
  349. $('#DeviceTask_List').append("" +
  350. "<div class=\"layui-btn layui-border-blue\" style=\"height: 60px;padding-top: 8px;background-color: #02b51e;\" " +
  351. "onclick=\" T_Ut_start = '" + T_Ut_start + "';T_Ut_end = '" + T_Ut_end + "';get_DeviceSensor_data()\" >\n" +
  352. " <div style=\"height: 15px;\">"+T_Ut_start+"</div>\n" +
  353. " <div style=\"height: 15px;\">"+T_Ut_end+"</div>\n" +
  354. "</div>")
  355. }
  356. }
  357. function get_DeviceSensor_list(page) {
  358. T_sn = $("#D_T_sn").val();
  359. T_name = $("#D_Name").val();
  360. T_class_id = $("#Class_1").val();
  361. $.ajax({
  362. type: 'POST',
  363. url: 'Device_Sensor_List',//发送请求
  364. data: {
  365. User_tokey: $.cookie("User_tokey"),
  366. T_sn: T_sn,
  367. T_name: T_name,
  368. T_class_id: parseInt(T_class_id),
  369. page: page,
  370. SN_type: "YD",
  371. },
  372. success: function (result) {
  373. console.log(result)
  374. if (result.Code == 200) {
  375. $('#DeviceSensor_list').html("")
  376. $('#DeviceSensor_list_Pages').html("")
  377. $('#DeviceSensor_list_Pages_x').html("")
  378. DeviceSensor_lite = result.Data.DeviceSensor_lite
  379. if (DeviceSensor_lite.length == 0) {
  380. $('#DeviceSensor_list').html("<div style=\"color: #1E9FFF;text-align: center;font-size: 15px;margin-top: 150px\">没有设备</div>")
  381. return
  382. }
  383. Add_DeviceSensor_list(result.Data.DeviceSensor_lite) // 列表
  384. Add_DeviceSensor_list_Pages(result.Data.Pages) // 分页
  385. $('#DeviceSensor_list_Pages_x').append("页数:" + result.Data.Page + "/" + result.Data.Page_size + " 总数:" + result.Data.Num);
  386. } else {
  387. }
  388. }
  389. });
  390. return false
  391. }
  392. function Add_DeviceSensor_list(DS_lite) {
  393. for (let i = 0; i < DS_lite.length; i++) {
  394. if(T_id == 0){
  395. T_id = DS_lite[i].T_id;
  396. T_sn_T_id = DS_lite[i].T_sn;
  397. f_DeviceTask_List()
  398. }
  399. $('#DeviceSensor_list').append("" +
  400. "<div class=\"layui-col ChangeDiv\" onclick=\"ChangeDiv(this); T_id = " + DS_lite[i].T_id + ";T_sn_T_id = '" + DS_lite[i].T_sn + "';f_DeviceTask_List()\" \n" +
  401. " style=\"border: 1px solid #ffffff;height: 52px;background-color: #fafafa;border-radius:5px;padding-top: 2px;margin-top: 6px\">\n" +
  402. " <img style=\"float: left;width: 50px;margin: 0px 10px\" src=\"https://osscold.baozhida.cn/images/温湿度传感器-1.png\"\n" +
  403. " height=\"50\"\n" +
  404. " width=\"40\"/>\n" +
  405. " <div style=\"float: left;\">\n" +
  406. " <div style=\"margin-top: 4px;font-size: 14px;height: 24px;\">" + DS_lite[i].T_name + "</div>\n" +
  407. " <div style=\"margin-top: -3px;font-size: 12px\">SN:" + DS_lite[i].T_sn + " [" + DS_lite[i].T_id + "]</div>\n" +
  408. " </div>\n" +
  409. " <div class=\"layui-card-header\"\n" +
  410. " style=\"float: right;padding-left: 0px;padding-top: 6px;color: #1E9FFF\">\n" +
  411. " 》\n" +
  412. " </div>\n" +
  413. " </div>")
  414. }
  415. }
  416. function Add_DeviceSensor_list_Pages(Pages) {
  417. for (let i = 0; i < Pages.length; i++) {
  418. elem = Pages[i]
  419. switch (elem.A) {
  420. case 1:
  421. $('#DeviceSensor_list_Pages').append("<a class=\"prev\" onclick='get_DeviceSensor_list(" + elem.V + ")' >&lt;&lt;</a>\n");
  422. break;
  423. case 2:
  424. $('#DeviceSensor_list_Pages').append("<a class=\"num\" onclick='get_DeviceSensor_list(" + elem.V + ")' >" + elem.V + "</a>\n");
  425. break;
  426. case 3:
  427. $('#DeviceSensor_list_Pages').append("<span class=\"current\">" + elem.V + "</span>\n");
  428. break;
  429. case 4:
  430. $('#DeviceSensor_list_Pages').append("<a class=\"num\" onclick='get_DeviceSensor_list(" + elem.V + ")' >" + elem.V + "</a>\n");
  431. break;
  432. case 5:
  433. $('#DeviceSensor_list_Pages').append("<a class=\"next\" onclick='get_DeviceSensor_list(" + elem.V + ")' >&gt;&gt;</a>\n");
  434. break;
  435. }
  436. }
  437. }
  438. function on_get_DeviceSensor_data() {
  439. T_Ut_start = $("#Time_start").val().replace("+", ' ');
  440. T_Ut_end = $("#Time_end").val().replace("+", ' ');
  441. get_DeviceSensor_data()
  442. }
  443. function get_DeviceSensor_data() {
  444. $.ajax({
  445. type: 'POST',
  446. url: 'Device_Sensor_Data',//发送请求
  447. data: {
  448. Time_start:T_Ut_start,
  449. Time_end:T_Ut_end,
  450. T_sn: T_sn_T_id,
  451. T_id: T_id,
  452. page: 0,
  453. page_z: 9000,
  454. },
  455. success: function (result) {
  456. console.log(result)
  457. if (result.Code == 200) {
  458. DeviceSensor_data = result.Data.DeviceSensor_data
  459. T_fhand(result.Data.DeviceSensor_data)
  460. } else {
  461. }
  462. }
  463. });
  464. return false
  465. }
  466. //// --------- 地图
  467. var graspRoad;
  468. function T_fhand(data) {
  469. var map = new AMap.Map('container', {
  470. resizeEnable: true,
  471. center: [104.101765,41.561402],
  472. zoom: 4
  473. });
  474. var lineArr = [
  475. // ['75.757904', '38.118117'],
  476. // ['117.375719', '24.598057']
  477. ];
  478. if(!data) {
  479. return
  480. }
  481. for (let i = 0; i < data.length; i++) {
  482. // 026.5610665,106.6644807
  483. if(data[i].T_site.length < 5){
  484. continue;
  485. }
  486. T_site_split = data[i].T_site.split(",")
  487. // 地理经纬度坐标
  488. var lon = parseFloat(T_site_split[1]);
  489. var lat = parseFloat(T_site_split[0]);
  490. // console.log(data,lon,lat)
  491. lineArr.unshift(new AMap.LngLat(lon,lat)) //unshift push
  492. }
  493. console.log("lineArr:",lineArr)
  494. if(!graspRoad) {
  495. graspRoad = new AMap.GraspRoad()
  496. }
  497. // 坐标转换
  498. AMap.convertFrom(lineArr, 'gps', function (status, result) {
  499. if (result.info === 'ok') {
  500. var path2 = result.locations;
  501. console.log("path2:",path2)
  502. var polyline = new AMap.Polyline({
  503. path: path2,
  504. isOutline: true,
  505. outlineColor: '#ffeeff',
  506. borderWeight: 3,
  507. strokeColor: "#3366FF",
  508. strokeOpacity: 1,
  509. strokeWeight: 6,
  510. // 折线样式还支持 'dashed'
  511. strokeStyle: "solid",
  512. // strokeStyle是dashed时有效
  513. strokeDasharray: [10, 5],
  514. lineJoin: 'round',
  515. lineCap: 'round',
  516. zIndex: 50,
  517. })
  518. // 创建一个 icon
  519. var endIcon = new AMap.Icon({
  520. size: new AMap.Size(25, 34),
  521. image: 'https://osscold.baozhida.cn/images/dir-marker.png',
  522. imageSize: new AMap.Size(135, 40),
  523. imageOffset: new AMap.Pixel(-95, -3)
  524. });
  525. // 将 icon 传入 marker
  526. var endMarker = new AMap.Marker({
  527. position: new AMap.LngLat(path2[path2.length-1].lng,path2[path2.length-1].lat),
  528. icon: endIcon,
  529. offset: new AMap.Pixel(-13, -30)
  530. });
  531. if(Admin_rh == 0 && T_sn_T_id.indexOf("YD") != -1){
  532. data[0].T_rh = "-"
  533. }
  534. AMap.event.addListener(endMarker, 'click', function () {
  535. //创建信息窗口
  536. infoWindow = new AMap.InfoWindow({
  537. isCustom: true, //使用自定义窗体
  538. content: "<div style='height: 28px;background-color: "+style_s+";border: 1px solid #ccc;padding: 2px;float: contour'>" +
  539. "<div style='background-color: #69d1ff;position: absolute;top: -15px;left: 1px;padding: 0px 4px'>终点</div>" +
  540. "<span style='background-color: #FF9E9E;padding: 0px 2px;line-height'>温度:"+data[0].T_t+"</span>"+
  541. "<span style='background-color: #52FEEC;margin-left: 6px;padding: 0px 2px;line-height'>湿度:"+data[0].T_rh+"</span><br>"+
  542. "<span style='line-height'>"+data[0].T_time+"</span></div>",
  543. offset: new AMap.Pixel(0, -30)
  544. });
  545. //打开信息窗口
  546. infoWindow.open(map, [path2[path2.length-1].lng,path2[path2.length-1].lat]); //后面的参数指的是经纬度,在此显示窗口
  547. });
  548. // 创建一个 Icon
  549. var startIcon = new AMap.Icon({
  550. // 图标尺寸
  551. size: new AMap.Size(25, 34),
  552. // 图标的取图地址
  553. image: 'https://osscold.baozhida.cn/images/dir-marker.png',
  554. // 图标所用图片大小
  555. imageSize: new AMap.Size(135, 40),
  556. // 图标取图偏移量
  557. imageOffset: new AMap.Pixel(-9, -3)
  558. });
  559. // 创建一个 Icon
  560. var dianIcon = new AMap.Icon({
  561. // 图标的取图地址
  562. image: 'https://osscold.baozhida.cn/images/poi-marker-default.png',
  563. size: new AMap.Size(22, 28), //图标所处区域大小
  564. imageSize: new AMap.Size(22,28) //图标大小
  565. });
  566. // 将 icon 传入 marker
  567. var startMarker = new AMap.Marker({
  568. position: new AMap.LngLat(path2[0].lng,path2[0].lat),
  569. icon: startIcon,
  570. offset: new AMap.Pixel(-13, -30)
  571. });
  572. if(Admin_rh == 0 && T_sn_T_id.indexOf("YD") != -1){
  573. data[data.length - 1].T_rh = "-"
  574. }
  575. AMap.event.addListener(startMarker, 'click', function () {
  576. //创建信息窗口
  577. infoWindow = new AMap.InfoWindow({
  578. isCustom: true, //使用自定义窗体
  579. content: "<div style='height: 28px;background-color: "+style_s+";border: 1px solid #ccc;padding: 2px;float: contour'>" +
  580. "<div style='background-color: #69d1ff;position: absolute;top: -15px;left: 1px;padding: 0px 4px'>起点</div>" +
  581. "<span style='background-color: #FF9E9E;padding: 0px 2px;line-height'>温度:"+data[data.length - 1].T_t+"</span>"+
  582. "<span style='background-color: #52FEEC;margin-left: 6px;padding: 0px 2px;line-height'>湿度:"+data[data.length - 1].T_rh+"</span><br>"+
  583. "<span style='line-height'>"+data[data.length - 1].T_time+"</span></div>",
  584. offset: new AMap.Pixel(0, -30)
  585. });
  586. //打开信息窗口
  587. infoWindow.open(map, [path2[0].lng,path2[0].lat]); //后面的参数指的是经纬度,在此显示窗口
  588. });
  589. list_marker = []
  590. // 所有 标记点 信息
  591. for (let ix = 0; ix < path2.length; ix++) {
  592. if(ix == 0 || ix == path2.length - 1){
  593. continue
  594. }
  595. var marker = new AMap.Marker({
  596. position: new AMap.LngLat(path2[ix].lng,path2[ix].lat),
  597. icon: dianIcon,
  598. });
  599. list_marker.push(marker)
  600. ddid = data.length - ix - 1 // -
  601. style_s = "#ffffff"
  602. if(data[ddid].T_t < data[ddid].T_Tlower || data[ddid].T_rh < data[ddid].T_RHlower){
  603. style_s = "#ff7070"
  604. }
  605. if(data[ddid].T_t > data[ddid].T_Tupper || data[ddid].T_rh > data[ddid].T_RHupper){
  606. style_s = "#ff7070"
  607. }
  608. // label默认蓝框白底左上角显示,样式className为:amap-marker-label
  609. // marker.setLabel({
  610. // offset: new AMap.Pixel(10, 0), //设置文本标注偏移量
  611. // content: "<spen style='background: transparent;'>"+ddid+"</spen>", //设置文本标注内容
  612. // direction: 'center' //设置文本标注方位
  613. // });
  614. if(Admin_rh == 0 && T_sn_T_id.indexOf("YD") != -1){
  615. data[ddid].T_rh = "-"
  616. }
  617. AMap.event.addListener(list_marker[list_marker.length - 1], 'click', function () {
  618. console.log("ix:",ix)
  619. ddid = data.length - ix - 1
  620. //创建信息窗口
  621. infoWindow = new AMap.InfoWindow({
  622. isCustom: true, //使用自定义窗体
  623. content: "<div style='height: 28px;background-color: "+style_s+";border: 1px solid #ccc;padding: 2px;float: contour'>" +
  624. "<div style='background-color: #69d1ff;position: absolute;top: -15px;left: 1px;padding: 0px 4px'>"+ddid+"</div>" +
  625. "<span style='background-color: #FF9E9E;padding: 0px 2px;line-height'>温度:"+data[ddid].T_t+"</span>"+
  626. "<span style='background-color: #52FEEC;margin-left: 6px;padding: 0px 2px;line-height'>湿度:"+data[ddid].T_rh+"</span><br>"+
  627. "<span style='line-height'>"+data[ddid].T_time+"</span></div>",
  628. offset: new AMap.Pixel(0, -30)
  629. });
  630. //打开信息窗口
  631. infoWindow.open(map, [path2[ix].lng,path2[ix].lat]); //后面的参数指的是经纬度,在此显示窗口
  632. });
  633. marker.setMap(map);
  634. }
  635. // 条纹
  636. var polyline1 = new AMap.Polyline({
  637. path:path2,
  638. strokeWeight:8,
  639. strokeOpacity:0.8,
  640. strokeColor:'#426dff',
  641. showDir:true
  642. });
  643. polyline1.setMap(map);
  644. map.add([ startMarker, endMarker]);
  645. map.setFitView(null, false, [150, 60, 100, 60]);
  646. //
  647. // // 轨迹纠偏
  648. // map.getCenter();
  649. // if(!graspRoad) {
  650. // graspRoad = new AMap.GraspRoad()
  651. // }
  652. // var pathParam = []
  653. // for(var i=0;i<path2.length;i+=1){
  654. // pathParam.push({"x":path2[i].R,"y":path2[i].Q,"sp":1,"ag":1, "tm":1})
  655. // }
  656. // console.log("pathParam:",pathParam)
  657. // graspRoad.driving(pathParam,function(error,result) {
  658. // if (!error) {
  659. // var path3 = [];
  660. // var newPath = result.data.points;
  661. // console.log("newPath:",newPath)
  662. // for (var i = 0; i < newPath.length; i += 1) {
  663. // path3.push([newPath[i].x, newPath[i].y])
  664. // }
  665. // var newLine = new AMap.Polyline({
  666. // path: path3,
  667. // strokeWeight: 8,
  668. // strokeOpacity: 0.8,
  669. // strokeColor: '#0091ea',
  670. // showDir: true
  671. // })
  672. // map.add(newLine)
  673. // map.setFitView()
  674. // }else {
  675. // console.log(error)
  676. // }
  677. //
  678. // })
  679. //
  680. }
  681. });
  682. }
  683. function dateChangeFormat(format, date) {
  684. date = new Date(date);
  685. const dataItem = {
  686. 'Y+': date.getFullYear().toString(),
  687. 'm+': (date.getMonth() + 1).toString(),
  688. 'd+': date.getDate().toString(),
  689. 'H+': date.getHours().toString(),
  690. 'M+': date.getMinutes().toString(),
  691. 'S+': date.getSeconds().toString(),
  692. };
  693. Object.keys(dataItem).forEach((item) => {
  694. const ret = new RegExp(`(${item})`).exec(format);
  695. if (ret) {
  696. format = format.replace(ret[1], ret[1].length === 1 ? dataItem[item] : dataItem[item].padStart(ret[1].length, '0'));
  697. }
  698. });
  699. return format;
  700. }
  701. </script>
  702. <script src="https://webapi.amap.com/maps?v=1.4.15&key=f41c8fbdd908f420f6babe5ab38bf574&callback=init&plugin=AMap.GraspRoad"></script>
  703. <style>
  704. .amap-marker-label{
  705. background: transparent;
  706. }
  707. .layui-card-body{
  708. line-height: 16px;
  709. }
  710. #container .amap-marker-label{border:0 none;white-space: nowrap; margin: 0px;padding: 0px}
  711. </style>
  712. </html>