SH-demo(1).html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. <!DOCTYPE html>
  2. <html xmlns:th="http://www.thymeleaf.org" lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>首页</title>
  6. <!-- <script src="https://cdn.bootcdn.net/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script> -->
  7. <link rel="stylesheet" href="https://js.arcgis.com/3.16/esri/css/esri.css">
  8. <script src="http://10.48.37.32:8080/arcgis_js_api/library/3.16/rgis/Rinit.js"></script>
  9. <!-- <script src="https://js.arcgis.com/3.16/"></script> -->
  10. <style>
  11. html,
  12. body {
  13. height: 100%;
  14. width: 100%;
  15. margin: 0;
  16. padding: 0;
  17. }
  18. .webMap {
  19. height: 100%;
  20. width: 100%;
  21. }
  22. .legend {
  23. position: absolute;
  24. bottom: 120px;
  25. right: 24px;
  26. border-radius: 6px;
  27. background-color: #fff;
  28. display: flex;
  29. flex-direction: column;
  30. gap: 6px;
  31. z-index: 1;
  32. padding: 12px;
  33. }
  34. .legend>div {
  35. cursor: pointer;
  36. display: flex;
  37. align-items: center;
  38. }
  39. #define {
  40. cursor: pointer;
  41. background: #fff;
  42. padding: 12px;
  43. text-align: center;
  44. width: 100px;
  45. position: absolute;
  46. border-radius: 8px;
  47. }
  48. .info {
  49. border: 1px solid #ccc;
  50. position: absolute;
  51. left: 0;
  52. right: 0;
  53. width: 60%;
  54. margin: auto;
  55. margin-top: 100px;
  56. z-index: 1;
  57. background: #fff;
  58. padding-bottom: 12px;
  59. }
  60. .info>.head {
  61. display: flex;
  62. justify-content: space-between;
  63. align-items: center;
  64. padding: 0 12px;
  65. height: 40px;
  66. border-bottom: 1px solid #ccc;
  67. }
  68. .info>.content {
  69. display: flex;
  70. gap: 12px;
  71. padding: 12px;
  72. }
  73. .info>.content p {
  74. margin-top: 0px;
  75. margin-bottom: 6px;
  76. }
  77. .info>.foot {
  78. display: flex;
  79. justify-content: center;
  80. align-items: center;
  81. }
  82. .esriPopupWrapper>div:first-child,
  83. .esriPopupWrapper>div:nth-child(3) {
  84. display: none;
  85. }
  86. #cameraTop {
  87. width: 240px;
  88. height: 130px;
  89. }
  90. #cameraTop>foreignObject {
  91. width: 100%;
  92. height: 100%;
  93. }
  94. #cameraTop .content {
  95. font-size: 12px;
  96. width: 100%;
  97. height: 100%;
  98. border-radius: 6px;
  99. background: #fff;
  100. border: 1px solid #ccc;
  101. box-sizing: border-box;
  102. }
  103. #cameraTop .content>*:first-child {
  104. display: flex;
  105. justify-content: space-between;
  106. padding: 6px;
  107. border-bottom: 1px solid #ccc;
  108. text-overflow: ellipsis;
  109. overflow: hidden;
  110. }
  111. #cameraTop .content>*:first-child>div:first-child {
  112. font-weight: bold;
  113. font-size: 14px;
  114. }
  115. #cameraTop .content>*:first-child>div:last-child {
  116. cursor: pointer;
  117. transform: scale(1.3);
  118. }
  119. #cameraTop .content>*:first-child>div:last-child:hover {
  120. color: red;
  121. }
  122. #cameraTop .content>*:last-child {
  123. outline-style: none;
  124. padding: 6px;
  125. padding-top: 0;
  126. margin: 0;
  127. }
  128. #cameraTop .content>*:last-child li {
  129. margin-top: 10px;
  130. display: flex;
  131. justify-content: space-between;
  132. }
  133. .highligh {
  134. border: dashed #00f;
  135. border-radius: 10px;
  136. }
  137. .esriPopup .contentPane {
  138. padding: 0 !important;
  139. background-color: unset !important;
  140. }
  141. .outerPointer.left {
  142. z-index: 1;
  143. box-shadow: none;
  144. border-left: 1px solid #ccc;
  145. border-bottom: 1px solid #ccc;
  146. background: #fff;
  147. }
  148. .esriPopupWrapper {
  149. width: 200px !important;
  150. box-shadow: 0 4px 4px 0px #ccc !important;
  151. }
  152. #graphicsLayer3_layer>* {
  153. cursor: pointer;
  154. }
  155. .sizer .content {
  156. width: 100% !important;
  157. }
  158. #map111_graphics_layer {
  159. display: none !important;
  160. }
  161. </style>
  162. </head>
  163. <body>
  164. <div id="define" style="display: none;">
  165. <span>费奥军</span>
  166. <img src="" height="20" width="6" alt="">
  167. <span>费奥军11</span>
  168. <div>11231231</div>
  169. </div>
  170. <!-- <div id="cameraTop">
  171. <div class="content">
  172. <div>
  173. <div>XXX线路</div>
  174. <div>×</div>
  175. </div>
  176. <ul>
  177. <li><span>里程位置</span><span>k1+400km</span></li>
  178. <li><span>里程范围</span><span>k1+400km</span></li>
  179. <li><span>经纬度</span><span>k1+400km</span></li>
  180. </ul>
  181. </div>
  182. </div> -->
  183. <!-- <svg id="cameraTop" viewBox="0 0 220 122" font-size="12">
  184. <rect x="10" y="10" width="200" height="102" fill="#fff" stroke="#ccc" rx="6"></rect>
  185. <g>
  186. <text x="18" y="28">XXX线路</text>
  187. <text x="190" y="28">X</text>
  188. </g>
  189. <line x1="10" y1="38" x2="210" y2="38" stroke="#ccc"></line>
  190. <g>
  191. <text x="18" y="58">里程位置</text>
  192. <text x="200" y="58" text-anchor="end">k1+400km</text>
  193. </g>
  194. <g>
  195. <text x="18" y="78">里程范围</text>
  196. <text x="200" y="78" text-anchor="end">k1+400km</text>
  197. </g>
  198. <g>
  199. <text x="18" y="98">经纬度</text>
  200. <text x="200" y="98" style="text-anchor:end">k1+400km</text>
  201. </g>
  202. </svg> -->
  203. <!-- <div class=" info">
  204. <div class="head">
  205. <div>报警信息提示</div>
  206. <div>❓</div>
  207. </div>
  208. <div class="content">
  209. <img src="" width="200" height="100" alt="">
  210. <div>
  211. <p>报警线路xx线路</p>
  212. <p>危岩落石 ,上行, 里程位置k1+400km</p>
  213. <p>2023.01.02 01:30:00</p>
  214. </div>
  215. </div>
  216. <div class="foot">
  217. <div
  218. style="text-align: center;line-height: 36px;cursor: pointer;width: 100px;height: 36px;color: #fff;background-color: #2866dd;">
  219. 立即查看</div>
  220. <div onclick="infoShow()"
  221. style="border: 1px solid #2866dd ;text-align: center;line-height: 36px;cursor: pointer;;width: 100px;height: 36px;margin-left: 12px;">
  222. 我知道了</div>
  223. </div>
  224. </div> -->
  225. <div class="legend">
  226. <div>
  227. <img src="/map/blueTrain.png" width="32" height="32" alt="">
  228. 重车线
  229. </div>
  230. <div>
  231. <img src="/map/greenTrain.png" width="32" height="32" alt="">
  232. 空车线
  233. </div>
  234. </div>
  235. <div class="webMap" id="map111"></div>
  236. <script>
  237. function infoShow() {
  238. document.body.querySelector('.info').style.display = 'none'
  239. }
  240. function throttle(fn, delay) {
  241. let timer = null;
  242. return function () {
  243. let context = this;
  244. let args = arguments;
  245. if (!timer) {
  246. timer = setTimeout(function () {
  247. fn.apply(context, args);
  248. timer = null;
  249. }, delay);
  250. }
  251. }
  252. }
  253. self.addEventListener('message', (e) => {
  254. if (typeof e.data === "boolean") {
  255. cameraShow = e.data
  256. cameraPoints.forEach(({ graphic }) => {
  257. e.data ? graphic.show() : (graphic.hide(), map.infoWindow.hide())
  258. })
  259. return
  260. }
  261. const { type, data } = e.data
  262. if (type === 1)
  263. vehicleList = data
  264. else if (type === 2)
  265. cameraList = data
  266. else if (type === 3) {
  267. searchInfo = data;
  268. const cameraTops = self.document.querySelectorAll("#cameraTop")
  269. cameraTops?.forEach?.(item => {
  270. searchInfo.camera === item?.dataset?.index ?
  271. item.classList.add("highligh") :
  272. item.classList.remove("highligh")
  273. })
  274. }
  275. generatePoints()
  276. }, false)
  277. let mapLoaded = false
  278. let vehicleList = []
  279. let cameraList = []
  280. let blue
  281. let green
  282. let camera
  283. let panelPoints = []
  284. let cameraPoints = []
  285. let cameraShow = true
  286. let searchInfo = {
  287. camera: '',
  288. vehicle: ''
  289. }
  290. let topInfo = {
  291. 1: {
  292. start: '神池南',
  293. end: '黄骅港'
  294. },
  295. 2: {
  296. start: '神池南',
  297. end: '黄骅港'
  298. }
  299. }
  300. var map;
  301. var graphicsLayer;
  302. var mapObject;
  303. var Point
  304. var PictureMarkerSymbol
  305. var Graphic
  306. var webMercatorUtils
  307. var InfoTemplate
  308. var InfoWindow
  309. var GraphicsLayer
  310. require([
  311. "esri/map",
  312. "esri/InfoTemplate",
  313. "esri/dijit/InfoWindow",
  314. "esri/geometry/Extent",
  315. "esri/geometry/Point",
  316. "esri/geometry/Polyline",
  317. "esri/layers/ArcGISDynamicMapServiceLayer",
  318. "esri/layers/ArcGISTiledMapServiceLayer",
  319. "esri/layers/GraphicsLayer",
  320. "esri/symbols/SimpleLineSymbol",
  321. "esri/symbols/SimpleMarkerSymbol",
  322. "esri/symbols/TextSymbol",
  323. "esri/symbols/Font",
  324. "esri/Color",
  325. "esri/graphic",
  326. "esri/geometry/webMercatorUtils",
  327. "esri/SpatialReference",
  328. "esri/geometry/Circle",
  329. "esri/symbols/SimpleFillSymbol",
  330. "esri/symbols/PictureMarkerSymbol",
  331. "dojo/domReady!"
  332. ], function (Map, _InfoTemplate, _InfoWindow, Extent, _Point, Polyline, ArcGISDynamicMapServiceLayer, ArcGISTiledMapServiceLayer, _GraphicsLayer, SimpleLineSymbol,
  333. SimpleMarkerSymbol, TextSymbol, Font, Color, _Graphic, _webMercatorUtils, SpatialReference, Circle, SimpleFillSymbol, _PictureMarkerSymbol, SwipeTool) {
  334. Point = _Point
  335. PictureMarkerSymbol = _PictureMarkerSymbol
  336. Graphic = _Graphic
  337. webMercatorUtils = _webMercatorUtils
  338. InfoTemplate = _InfoTemplate
  339. InfoWindow = _InfoWindow
  340. GraphicsLayer = _GraphicsLayer
  341. map = new Map("map111", {
  342. logo: false,
  343. autoResize: true,
  344. // sliderPosition: "bottom-right",
  345. center: [114.906005859375, 38.38897705078125],
  346. scale: 4017396,
  347. });
  348. var layer = new ArcGISDynamicMapServiceLayer("http://10.48.37.32:8080/OneMapServer/rest/services/BaseMap_write/MapServer")
  349. // var layer = new ArcGISDynamicMapServiceLayer("https://services.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer")
  350. var xlLayer = new ArcGISDynamicMapServiceLayer("http://10.48.37.32:8080/OneMapServer/rest/services/SH_XL/MapServer")
  351. var czLayer = new ArcGISDynamicMapServiceLayer("http://10.48.37.32:8080/OneMapServer/rest/services/SH_CZ/MapServer")
  352. map.addLayer(layer);
  353. map.addLayer(xlLayer);
  354. map.addLayer(czLayer);
  355. graphicsLayer = new GraphicsLayer()
  356. map.addLayer(graphicsLayer)
  357. map.on('load', () => {
  358. mapLoaded = true
  359. blue = new PictureMarkerSymbol('/map/blueTrain.png', 32, 32)
  360. green = new PictureMarkerSymbol('/map/greenTrain.png', 32, 32)
  361. camera = new PictureMarkerSymbol('/map/camera1.png', 60, 60)
  362. // camera = new PictureMarkerSymbol('https://bpic.588ku.com/element_origin_min_pic/16/10/28/d438fb1a4c9de459ff7736b050f77199.jpg', 32, 32)
  363. // blue = new PictureMarkerSymbol('https://img0.baidu.com/it/u=1482373880,50717570&fm=253&fmt=auto&app=138&f=JPG?w=500&h=500', 32, 32)
  364. generatePoints()
  365. })
  366. graphicsLayer.on('click', (e) => {
  367. console.log(e, 1111111)
  368. e.graphic.symbol.data &&
  369. self.parent.postMessage({
  370. name: e.graphic.symbol.name,
  371. data: e.graphic.symbol.data
  372. })
  373. // if (e.graphic?.attributes?.show) {
  374. // if (cameraPoints[e.graphic.attributes.index].active) {
  375. // cameraPoints[e.graphic.attributes.index].active = false
  376. // cameraPoints[e.graphic.attributes.index].topPanel.hide()
  377. // } else {
  378. // cameraPoints[e.graphic.attributes.index].active = true
  379. // cameraPoints[e.graphic.attributes.index].topPanel.show()
  380. // }
  381. // }
  382. })
  383. })
  384. const vehicleList1 = [
  385. {
  386. "ids": null,
  387. "id": 79,
  388. "vehicleCode": "HXD1 7084A",
  389. "vehicleName": "",
  390. "createBy": "af09aac6340744d6be5b64b1697d7415",
  391. "createTime": "2023-10-18 15:05:32",
  392. "updateBy": "c0917e58bb254c7b825a6ce974e42d96",
  393. "updateTime": "2023-10-19 09:58:19",
  394. "terminalName": "车载终端01",
  395. "remark": "神华号",
  396. "vehicleTerminalDto": {
  397. "id": "44",
  398. "terminalCode": "CZZD06",
  399. "vehicleCode": "HXD1 7084A",
  400. "vehicleName": null,
  401. "lineDir": "2",
  402. "travelMile": 196500,
  403. "terminalLongitude": "114.38200",
  404. "terminalLatitude": "39.2284",
  405. "railwayName": null,
  406. "railwayCode": "SHTL"
  407. }
  408. },
  409. {
  410. "ids": null,
  411. "id": 80,
  412. "vehicleCode": "HXD1 7084B",
  413. "vehicleName": "",
  414. "createBy": "af09aac6340744d6be5b64b1697d7415",
  415. "createTime": "2023-10-18 15:11:50",
  416. "updateBy": "c0917e58bb254c7b825a6ce974e42d96",
  417. "updateTime": "2023-10-19 09:58:13",
  418. "terminalName": "车载终端02",
  419. "remark": "神华号",
  420. "vehicleTerminalDto": {
  421. "id": "42",
  422. "terminalCode": "CZZD08",
  423. "vehicleCode": "HXD1 7084B",
  424. "vehicleName": null,
  425. "lineDir": "1",
  426. "travelMile": 49822,
  427. "terminalLongitude": "113.7253",
  428. "terminalLatitude": "38.3942",
  429. "railwayName": null,
  430. "railwayCode": "SHTL"
  431. }
  432. }
  433. ]
  434. const cameraList1 = [
  435. {
  436. "ids": null,
  437. "id": 79,
  438. "vehicleCode": "HXD1 7084A",
  439. "vehicleName": "",
  440. "createBy": "af09aac6340744d6be5b64b1697d7415",
  441. "createTime": "2023-10-18 15:05:32",
  442. "updateBy": "c0917e58bb254c7b825a6ce974e42d96",
  443. "updateTime": "2023-10-19 09:58:19",
  444. "terminalName": "车载终端01",
  445. "remark": "神华号",
  446. installLongitude: "115.7253",
  447. installLatitude: "38.3942",
  448. cameraCode: "123",
  449. "vehicleTerminalDto": {
  450. "id": "44",
  451. "terminalCode": "CZZD06",
  452. "vehicleCode": "HXD1 7084A",
  453. "vehicleName": null,
  454. "lineDir": "1",
  455. "travelMile": 48018,
  456. "terminalLongitude": "114.38200",
  457. "terminalLatitude": "39.2284",
  458. "railwayName": null,
  459. "railwayCode": "SHTL"
  460. }
  461. },
  462. {
  463. "ids": null,
  464. "id": 80,
  465. "vehicleCode": "HXD1 7084B",
  466. "vehicleName": "",
  467. "createBy": "af09aac6340744d6be5b64b1697d7415",
  468. "createTime": "2023-10-18 15:11:50",
  469. "updateBy": "c0917e58bb254c7b825a6ce974e42d96",
  470. "updateTime": "2023-10-19 09:58:13",
  471. "terminalName": "车载终端02",
  472. "remark": "神华号",
  473. installLongitude: "114.7253",
  474. installLatitude: "38.3942",
  475. cameraCode: "234",
  476. "vehicleTerminalDto": {
  477. "id": "42",
  478. "terminalCode": "CZZD08",
  479. "vehicleCode": "HXD1 7084B",
  480. "vehicleName": null,
  481. "lineDir": "1",
  482. "travelMile": 49822,
  483. "terminalLongitude": "113.7253",
  484. "terminalLatitude": "38.3942",
  485. "railwayName": null,
  486. "railwayCode": "SHTL"
  487. }
  488. }
  489. ]
  490. function createTopPanelGraphic(point, item) {
  491. const scale = 2;
  492. let width = 160 * scale, height = 80 * scale
  493. const arrowLen = 50
  494. const cvs = document.createElement('canvas')
  495. cvs.width = width
  496. cvs.height = height
  497. const ctx = cvs.getContext('2d')
  498. ctx.translate(0.5, 0.5)
  499. ctx.save()
  500. ctx.beginPath()
  501. ctx.roundRect(20, 20, width - 40, height - 40, 6)
  502. ctx.fillStyle = '#fff'
  503. ctx.strokeStyle = '#ccc'
  504. ctx.shadowColor = item.data.lineDir === 1 ? '#006aef' : '#38e731'
  505. // ctx.shadowOffsetY = 4
  506. ctx.shadowBlur = 20
  507. ctx.stroke()
  508. ctx.fill()
  509. ctx.restore()
  510. if (searchInfo.vehicle === item.id) {
  511. ctx.save()
  512. ctx.beginPath()
  513. ctx.lineWidth = 4
  514. ctx.strokeStyle = '#00f'
  515. ctx.setLineDash([5, 5])
  516. ctx.roundRect(20, 20, width - 40, height - 40, 6)
  517. ctx.stroke()
  518. ctx.restore()
  519. }
  520. ctx.fillStyle = '#000'
  521. ctx.font = `bold ${12 * scale}px serif`
  522. ctx.textAlign = "right"
  523. ctx.fillText(item.direct ? item.start : item.end, width / 2 - arrowLen / 2 - 10, 30 * scale)
  524. // const x = width / 2 - arrowLen / 2, y = 20 * scale + 4 * scale, w = arrowLen - 10, h = 4 * scale
  525. const w = arrowLen - 10, h = 4 * scale
  526. ctx.save()
  527. ctx.translate(width / 2 - arrowLen / 2 + (arrowLen - 10) / 2, 20 * scale + 4 * scale + 4 * scale / 2)
  528. if (item.direct) {
  529. ctx.fillRect(-w / 2, -h / 2, w, h)
  530. ctx.fill(new Path2D(`m${arrowLen / 2 - 10} ${-h / 2 - 4}L${arrowLen / 2} 0L${arrowLen / 2 - 10} ${h / 2 + 4}z`))
  531. }
  532. else {
  533. ctx.rotate(Math.PI)
  534. ctx.fillRect(-w / 2, -h / 2, w, h)
  535. ctx.fill(new Path2D(`m${arrowLen / 2 - 10} ${-h / 2 - 4}L${arrowLen / 2} 0L${arrowLen / 2 - 10} ${h / 2 + 4}z`))
  536. }
  537. ctx.restore()
  538. ctx.textAlign = "left"
  539. ctx.fillText(item.direct ? item.end : item.start, width / 2 + arrowLen / 2 + 10, 30 * scale)
  540. ctx.textAlign = "center"
  541. ctx.fillText(item.code, width / 2, height - 20 * scale)
  542. const url = cvs.toDataURL('image/png', 1)
  543. const symbol = new PictureMarkerSymbol({ url, width: 160, height: 80, yoffset: 52, name: item.name, data: item.data })
  544. return new Graphic(point, symbol)
  545. }
  546. function createCameraInfo(point, item) {
  547. const temp = document.querySelector('#cameraTop').cloneNode(true)
  548. temp.style.display = 'block'
  549. const svgUrl = new XMLSerializer().serializeToString(temp)
  550. try {
  551. const url = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(svgUrl)))
  552. return new Graphic(point, new PictureMarkerSymbol({ url, width: 220, height: 122, yoffset: 52 }))
  553. } catch (e) {
  554. console.error(e)
  555. }
  556. }
  557. function closeInfo(index) {
  558. map.infoWindow.hide()
  559. }
  560. function generatePoints() {
  561. if (!mapLoaded) return
  562. graphicsLayer.clear()
  563. panelPoints = []
  564. cameraPoints = []
  565. for (let i = 0; i < vehicleList.length; i++) {
  566. const item = vehicleList[i];
  567. console.log(i, item)
  568. let picSymbol
  569. if (item.vehicleTerminalDto?.lineDir === 1)
  570. picSymbol = blue
  571. else if (item.vehicleTerminalDto?.lineDir === 2)
  572. picSymbol = green
  573. var point = new Point(parseFloat(+item.vehicleTerminalDto?.terminalLongitude), parseFloat(+item.vehicleTerminalDto?.terminalLatitude), map.spatialReference);
  574. panelPoints.push({ point, item })
  575. var webMercator = webMercatorUtils.geographicToWebMercator(point);
  576. point.x = webMercator.x
  577. point.y = webMercator.y
  578. picSymbol.name = item.remark
  579. const lineDir = item.vehicleTerminalDto?.lineDir
  580. picSymbol.data = {
  581. lineDir: lineDir,
  582. travelMile: item.vehicleTerminalDto?.travelMile,
  583. railwayCode: item.vehicleTerminalDto?.railwayCode
  584. }
  585. const graphic = new Graphic(point, picSymbol, item, '')
  586. graphicsLayer.add(graphic)
  587. graphicsLayer.add(createTopPanelGraphic(point, {
  588. start: topInfo[lineDir]?.start, end: topInfo[lineDir]?.end, code: '火车编号:' + item.vehicleTerminalDto?.vehicleCode, direct: lineDir === 1,
  589. id: item.vehicleTerminalDto?.vehicleCode,
  590. name: item.remark,
  591. data: picSymbol.data
  592. })); // direct表示箭头方向:true向右,false向左
  593. }
  594. for (let i = 0; i < cameraList.length; i++) {
  595. const item = cameraList[i];
  596. var point = new Point(parseFloat(+item.installLongitude), parseFloat(+item.installLatitude), map.spatialReference);
  597. var webMercator = webMercatorUtils.geographicToWebMercator(point);
  598. point.x = webMercator.x
  599. point.y = webMercator.y
  600. const graphic = new Graphic(point, camera, { show: true, data: item, index: i, active: false }, '')
  601. const topPanel = new InfoTemplate(item.vehicleCode, `
  602. <div id="cameraTop" data-index="${item.cameraCode}" class="${item.cameraCode === searchInfo.camera ? 'highligh' : ''}">
  603. <div class="content">
  604. <div>
  605. <div>${item.railwayName}</div>
  606. <div onclick="closeInfo(${i})">×</div>
  607. </div>
  608. <ul>
  609. <li><span>里程位置</span><span>${item.installMiles}</span></li>
  610. <li><span>里程范围</span><span>${item.milesRange}</span></li>
  611. <li><span>经纬度</span><span>${item.installLatitude},${item.installLongitude}</span></li>
  612. </ul>
  613. </div>
  614. </div>
  615. `)
  616. map.infoWindow.anchor = 'top'
  617. graphic.setInfoTemplate(topPanel)
  618. graphicsLayer.add(graphic)
  619. cameraPoints.push({ graphic, topPanel, point });
  620. cameraShow ? graphic.show() : graphic.hide();
  621. // graphic.draw()
  622. if (searchInfo.camera === item.cameraCode) {
  623. // map.infoWindow.show(point)
  624. map.infoWindow.show(point);
  625. map.infoWindow.setFeatures([graphic]);
  626. }
  627. }
  628. }
  629. </script>
  630. </body>
  631. </html>