Layer.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. /**
  2. * 图层加载工具类
  3. */
  4. import {onLocationBoat, setBoat} from '@/utils/map/Boat'
  5. import {
  6. addGraphic,
  7. addLayer,
  8. clearMap,
  9. getMapExtent,
  10. getMapScale,
  11. setOpacity,
  12. setShowDepthPointsState
  13. } from "@/utils/map/ArcgisUtil";
  14. import {setCenter,setSxdxCamera} from '@/utils/map/Common'
  15. import {GetHpjDepthPoints} from '@/apis/hdsj'
  16. import layerConfig from '@/config/layerConfig'
  17. // let layerList = ['cb','mt','jjq','dtq','md','sszh','hb','hd','sxdx','2023.1','2022.1','2022.2','2021.1','2021.2','2020.1','2020.2']
  18. let layerList = []
  19. let depthInterval
  20. let depthParams
  21. // let currentDepthYear
  22. let showDepthPoints = false
  23. let defaultLayerList = [
  24. {
  25. // 水上客运
  26. id: 'waterPassenger',
  27. title: 'waterPassenger',
  28. type: 'feature',
  29. url: layerConfig.waterPassengerLayer,
  30. visible: false,
  31. opacity: 1,
  32. token: '',
  33. is_goto: false
  34. },
  35. {
  36. // 数字孪生图层
  37. id: 'digitalTwain',
  38. title: 'digitalTwain',
  39. type: 'feature',
  40. url: layerConfig.digitalTwinLayer,
  41. visible: false,
  42. opacity: 1,
  43. token: '',
  44. is_goto: false
  45. },
  46. {
  47. // 地图查询图层
  48. id: 'ghjgCxall',
  49. title: 'ghjgCxall',
  50. type: 'shc_map',
  51. url:layerConfig.ghjgCxAllLayer,
  52. visible: false,
  53. opacity: 1,
  54. token: '',
  55. is_goto: false
  56. }
  57. ]
  58. export function addDefaultServer(){
  59. for (let i = 0; i < defaultLayerList.length; i++) {
  60. let layerObject = defaultLayerList[i];
  61. addLayer({
  62. id: layerObject.id,
  63. title: layerObject.title,
  64. type: layerObject.type,
  65. url: layerObject.url,
  66. visible: layerObject.visible,
  67. opacity: layerObject.opacity,
  68. token: layerObject.token,
  69. is_goto: layerObject.is_goto
  70. })
  71. }
  72. }
  73. export function closeAllLayer() {
  74. for (let i = layerList.length-1; i >=0;i--) {
  75. addLayerByName(layerList[i],false)
  76. }
  77. }
  78. export function addLayerByName(name,isShow,opacity){
  79. // 存储到打开图层列表
  80. if(isShow){
  81. let isExist = false
  82. for(let i = layerList.length-1; i >=0;i--){
  83. if(layerList[i] == name){
  84. isExist = true
  85. }
  86. }
  87. if(!isExist){
  88. layerList.push(name)
  89. }
  90. }else{
  91. for(let i = layerList.length-1; i >=0;i--){
  92. if(layerList[i] == name){
  93. layerList.splice(i,1)
  94. }
  95. }
  96. }
  97. console.log(layerList)
  98. switch (name) {
  99. // 船舶
  100. case 'cb':
  101. setBoat(isShow)
  102. break
  103. // 码头泊位
  104. case 'mt':
  105. addLayer({
  106. id: 'portLayer',
  107. title: 'portLayer',
  108. type: 'feature',
  109. url: layerConfig.digitalTwinLayer+'/0',
  110. visible: isShow,
  111. opacity: opacity?opacity:1,
  112. token: '',
  113. is_goto: true
  114. })
  115. break
  116. // 警戒区
  117. case 'jjq':
  118. addLayer({
  119. id: 'jjqIconLayer',
  120. title: 'jjqIconLayer',
  121. type: 'scene',
  122. url: layerConfig.jjqIconLayer,
  123. visible: isShow,
  124. opacity: opacity?opacity:1,
  125. token: '',
  126. is_goto: true
  127. })
  128. addLayer({
  129. id: 'jjqAreaLayer',
  130. title: 'jjqAreaLayer',
  131. type: 'feature',
  132. url: layerConfig.jjqLayer,
  133. visible: isShow,
  134. opacity: opacity?opacity:0.5,
  135. token: '',
  136. is_goto: true
  137. })
  138. break
  139. // 掉头区
  140. case 'dtq':
  141. addLayer({
  142. id: 'dtqIconLayer',
  143. title: 'dtqIconLayer',
  144. type: 'scene',
  145. url: layerConfig.dtqIconLayer,
  146. visible: isShow,
  147. opacity: opacity?opacity:1,
  148. token: '',
  149. is_goto: true
  150. })
  151. addLayer({
  152. id: 'dtqAreaLayer',
  153. title: 'dtqAreaLayer',
  154. type: 'feature',
  155. url: layerConfig.dtqLayer,
  156. visible: isShow,
  157. opacity: opacity?opacity:0.5,
  158. token: '',
  159. is_goto: true
  160. })
  161. break
  162. // 锚地
  163. case 'md':
  164. addLayer({
  165. id: 'mdIconLayer',
  166. title: 'mdIconLayer',
  167. type: 'scene',
  168. url: layerConfig.mdIconLayer,
  169. visible: isShow,
  170. opacity: opacity?opacity:1,
  171. token: '',
  172. is_goto: true
  173. })
  174. addLayer({
  175. id: 'mdAreaLayer',
  176. title: 'mdAreaLayer',
  177. type: 'feature',
  178. url: layerConfig.mdLayer,
  179. visible: isShow,
  180. opacity: opacity?opacity:0.5,
  181. token: '',
  182. is_goto: true
  183. })
  184. break
  185. // 水上综合绿色服务器
  186. case 'sszh':
  187. addLayer({
  188. id: 'ssfwqIconLayer',
  189. title: 'ssfwqIconLayer',
  190. type: 'scene',
  191. url: layerConfig.sszhIconLayer,
  192. visible: isShow,
  193. opacity: opacity?opacity:1,
  194. token: '',
  195. is_goto: true
  196. })
  197. addLayer({
  198. id: 'ssfwqAreaLayer',
  199. title: 'ssfwqAreaLayer',
  200. type: 'feature',
  201. url: layerConfig.sszhLayer,
  202. visible: isShow,
  203. opacity: opacity?opacity:0.5,
  204. token: '',
  205. is_goto: true
  206. })
  207. break
  208. // 航标
  209. case 'hb':
  210. addLayer({
  211. id: 'hbSceneLayer',
  212. title: 'hbSceneLayer',
  213. type: 'scene',
  214. url: layerConfig.hbLayer,
  215. visible: isShow,
  216. opacity: opacity?opacity:1,
  217. token: '',
  218. is_goto: true
  219. })
  220. break
  221. // 航道
  222. case 'hd':
  223. addLayer({
  224. id: 'channelLayer',
  225. title: 'channelLayer',
  226. type: 'feature',
  227. url: layerConfig.digitalTwinLayer+'/2',
  228. visible: isShow,
  229. opacity: opacity?opacity:1,
  230. token: '',
  231. is_goto: true
  232. })
  233. break
  234. // 水下地形
  235. case 'sxdx':
  236. addLayer({
  237. id: 'dbsLayer',
  238. title: 'dbsLayer',
  239. type: 'scene',
  240. url: layerConfig.sxdxLayer202301,
  241. visible: isShow,
  242. opacity: opacity?opacity:1,
  243. token: '',
  244. is_goto: true
  245. })
  246. // if(isShow){
  247. // setOpacity(0.4)
  248. // setSxdxCamera()
  249. // }else{
  250. // setOpacity(1)
  251. // setCenter()
  252. // }
  253. break
  254. case '2023.1':
  255. addLayer({
  256. id: 'deepthLayer202301',
  257. title: 'deepthLayer202301',
  258. type: 'scene',
  259. url: layerConfig.sxdxLayer202301,
  260. visible: isShow,
  261. opacity: opacity?opacity:1,
  262. token: '',
  263. is_goto: true
  264. })
  265. break
  266. case '2023.2':
  267. addLayer({
  268. id: 'deepthLayer202302',
  269. title: 'deepthLayer202302',
  270. type: 'scene',
  271. url: layerConfig.sxdxLayer202302,
  272. visible: isShow,
  273. opacity: opacity?opacity:1,
  274. token: '',
  275. is_goto: true
  276. })
  277. break
  278. case '2022.1':
  279. addLayer({
  280. id: 'deepthLayer202201',
  281. title: 'deepthLayer202201',
  282. type: 'scene',
  283. url: layerConfig.sxdxLayer202201,
  284. visible: isShow,
  285. opacity: opacity?opacity:1,
  286. token: '',
  287. is_goto: false
  288. })
  289. break
  290. case '2022.2':
  291. addLayer({
  292. id: 'deepthLayer202202',
  293. title: 'deepthLayer202202',
  294. type: 'scene',
  295. url: layerConfig.sxdxLayer202202,
  296. visible: isShow,
  297. opacity: 1,
  298. token: '',
  299. is_goto: false
  300. })
  301. break
  302. case '2021.1':
  303. addLayer({
  304. id: 'deepthLayer202101',
  305. title: 'deepthLayer202101',
  306. type: 'scene',
  307. url: layerConfig.sxdxLayer202101,
  308. visible: isShow,
  309. opacity: 1,
  310. token: '',
  311. is_goto: false
  312. })
  313. break
  314. case '2021.2':
  315. addLayer({
  316. id: 'deepthLayer202102',
  317. title: 'deepthLayer202102',
  318. type: 'scene',
  319. url: layerConfig.sxdxLayer202202,
  320. visible: isShow,
  321. opacity: 1,
  322. token: '',
  323. is_goto: false
  324. })
  325. break
  326. case '2020.1':
  327. addLayer({
  328. id: 'deepthLayer202001',
  329. title: 'deepthLayer202001',
  330. type: 'scene',
  331. url: layerConfig.sxdxLayer202001,
  332. visible: isShow,
  333. opacity: 1,
  334. token: '',
  335. is_goto: false
  336. })
  337. break
  338. case '2020.2':
  339. addLayer({
  340. id: 'deepthLayer202002',
  341. title: 'deepthLayer202002',
  342. type: 'scene',
  343. url: layerConfig.sxdxLayer202002,
  344. visible: isShow,
  345. opacity: 1,
  346. token: '',
  347. is_goto: false
  348. })
  349. break
  350. // 两岸白膜
  351. case 'bm':
  352. addLayer({
  353. id: 'hpj500mBuildingLayer',
  354. title: 'hpj500mBuildingLayer',
  355. type: 'scene',
  356. url: layerConfig.labmhPJ500Layer,
  357. visible: isShow,
  358. opacity: 1,
  359. token: '',
  360. is_goto: false
  361. })
  362. addLayer({
  363. id: 'pxBuildingLayer',
  364. title: 'pxBuildingLayer',
  365. type: 'scene',
  366. url: layerConfig.labmPxLayer,
  367. visible: isShow,
  368. opacity: 1,
  369. token: '',
  370. is_goto: false
  371. })
  372. break
  373. // 两岸精膜
  374. case 'jm':
  375. addLayer({
  376. id: 'jmBuildingLayer',
  377. title: 'jmBuildingLayer',
  378. type: 'scene',
  379. url: layerConfig.lajmLayer,
  380. visible: isShow,
  381. opacity: 1,
  382. token: '',
  383. is_goto: false
  384. })
  385. break
  386. // 客运码头
  387. case 'kymt':
  388. addLayer({
  389. id: 'kymtLayer',
  390. title: 'kymtLayer',
  391. type: 'scene',
  392. url: layerConfig.kymtLayer,
  393. visible: isShow,
  394. opacity: 1,
  395. token: '',
  396. is_goto: false
  397. })
  398. break
  399. // 淤积预警
  400. case 'yjyj':
  401. addLayer({
  402. id: 'yjyjLayer',
  403. title: 'yjyjLayer',
  404. type: 'scene',
  405. url: layerConfig.yjyjLayer202301,
  406. visible: isShow,
  407. opacity: opacity?opacity:1,
  408. token: '',
  409. is_goto: true
  410. })
  411. if(isShow){
  412. addLayer({
  413. id: 'dbsLayer',
  414. title: 'dbsLayer',
  415. type: 'scene',
  416. url: layerConfig.sxdxLayer202301,
  417. visible: false,
  418. opacity: 1,
  419. token: '',
  420. is_goto: true
  421. })
  422. addLayer({
  423. id: 'dbsLayer',
  424. title: 'dbsLayer',
  425. type: 'scene',
  426. url: layerConfig.sxdxLayer202301,
  427. visible: true,
  428. opacity: 0.4,
  429. token: '',
  430. is_goto: false
  431. })
  432. }else{
  433. addLayer({
  434. id: 'dbsLayer',
  435. title: 'dbsLayer',
  436. type: 'scene',
  437. url: layerConfig.sxdxLayer202301,
  438. visible: false,
  439. opacity: 1,
  440. token: '',
  441. is_goto: true
  442. })
  443. addLayer({
  444. id: 'dbsLayer',
  445. title: 'dbsLayer',
  446. type: 'scene',
  447. url: layerConfig.sxdxLayer202301,
  448. visible: true,
  449. opacity: 1,
  450. token: '',
  451. is_goto: false
  452. })
  453. }
  454. break
  455. // 疏浚前_22年陆家嘴弯道
  456. case '2022LjzBefore':
  457. addLayer({
  458. id: '2022LjzBefore',
  459. title: '2022LjzBefore',
  460. type: 'scene',
  461. url: layerConfig.LjzSjBefore2022,
  462. visible: isShow,
  463. opacity: 1,
  464. token: '',
  465. is_goto: false
  466. })
  467. break
  468. // 疏浚后_22年陆家嘴弯道
  469. case '2022LjzAfter':
  470. addLayer({
  471. id: '2022LjzAfterLayer',
  472. title: '2022LjzAfterLayer',
  473. type: 'scene',
  474. url: layerConfig.LjzSjAfter2022,
  475. visible: isShow,
  476. opacity: 1,
  477. token: '',
  478. is_goto: false
  479. })
  480. break
  481. // 危险品码头
  482. case 'wxpmt':
  483. addLayer({
  484. id: 'dangerPortLayer',
  485. title: 'dangerPortLayer',
  486. type: 'scene',
  487. url: layerConfig.wxpmtLayer,
  488. visible: isShow,
  489. opacity: opacity?opacity:1,
  490. token: '',
  491. elevationInfo: {
  492. "mode": "absolute-height",
  493. "offset": 0.1
  494. }
  495. })
  496. break
  497. // 水深剖面
  498. case 'pm_2020.1':
  499. addLayer({
  500. id: 'warterDepthLine2020H1Layer',
  501. title: 'warterDepthLine2020H1Layer',
  502. type: 'scene',
  503. url: layerConfig.dm2020H1Layer,
  504. visible: isShow,
  505. opacity: opacity?opacity:1,
  506. token: ''
  507. })
  508. var data = {'distance': 100, 'year': 2020.1}
  509. if(isShow){
  510. if(getMapScale() <= 5000) {
  511. getDeepthPoints(data)
  512. }
  513. }else{
  514. clearMap({is_draw: true, is_search:true, layers: []})
  515. }
  516. setDepthState(data,isShow)
  517. break
  518. case 'pm_2020.2':
  519. addLayer({
  520. id: 'warterDepthLine2020H2Layer',
  521. title: 'warterDepthLine2020H2Layer',
  522. type: 'scene',
  523. url: layerConfig.dm2020H2Layer,
  524. visible: isShow,
  525. opacity: opacity?opacity:1,
  526. token: ''
  527. })
  528. var data = {'distance': 100, 'year': 2020.2}
  529. if(isShow){
  530. if(getMapScale() <= 5000) {
  531. getDeepthPoints(data)
  532. }
  533. }else{
  534. clearMap({is_draw: true, is_search:true, layers: []})
  535. }
  536. setDepthState(data,isShow)
  537. break
  538. // 水深剖面
  539. case 'pm_2021.1':
  540. addLayer({
  541. id: 'warterDepthLine2021H1Layer',
  542. title: 'warterDepthLine2021H1Layer',
  543. type: 'scene',
  544. url: layerConfig.dm2021H1Layer,
  545. visible: isShow,
  546. opacity: opacity?opacity:1,
  547. token: ''
  548. })
  549. var data = {'distance': 100, 'year': 2021.1}
  550. if(isShow){
  551. if(getMapScale() <= 5000) {
  552. getDeepthPoints(data)
  553. }
  554. }else{
  555. clearMap({is_draw: true, is_search:true, layers: []})
  556. }
  557. setDepthState(data,isShow)
  558. break
  559. case 'pm_2021.2':
  560. addLayer({
  561. id: 'warterDepthLine2021H2Layer',
  562. title: 'warterDepthLine2021H2Layer',
  563. type: 'scene',
  564. url: layerConfig.dm2021H2Layer,
  565. visible: isShow,
  566. opacity: opacity?opacity:1,
  567. token: ''
  568. })
  569. var data = {'distance': 100, 'year': 2021.2}
  570. if(isShow){
  571. if(getMapScale() <= 5000) {
  572. getDeepthPoints(data)
  573. }
  574. }else{
  575. clearMap({is_draw: true, is_search:true, layers: []})
  576. }
  577. setDepthState(data,isShow)
  578. break
  579. case 'pm_2022.1':
  580. addLayer({
  581. id: 'warterDepthLine2022H1Layer',
  582. title: 'warterDepthLine2022H1Layer',
  583. type: 'scene',
  584. url: layerConfig.dm2022H1Layer,
  585. visible: isShow,
  586. opacity: opacity?opacity:1,
  587. token: ''
  588. })
  589. var data = {'distance': 100, 'year': 2022.1}
  590. if(isShow){
  591. if(getMapScale() <= 5000) {
  592. getDeepthPoints(data)
  593. }
  594. }else{
  595. clearMap({is_draw: true, is_search:true, layers: []})
  596. }
  597. setDepthState(data,isShow)
  598. break
  599. case 'pm_2022.2':
  600. addLayer({
  601. id: 'warterDepthLine2022H2Layer',
  602. title: 'warterDepthLine2022H2Layer',
  603. type: 'scene',
  604. url: layerConfig.dm2022H2Layer,
  605. visible: isShow,
  606. opacity: opacity?opacity:1,
  607. token: ''
  608. })
  609. var data = {'distance': 100, 'year': 2022.2}
  610. if(isShow){
  611. if(getMapScale() <= 5000) {
  612. getDeepthPoints(data)
  613. }
  614. }else{
  615. clearMap({is_draw: true, is_search:true, layers: []})
  616. }
  617. setDepthState(data,isShow)
  618. break
  619. /* case 'pm_2023.1':
  620. addLayer({
  621. id: 'warterDepthLine2023H1Layer',
  622. title: 'warterDepthLine2023H1Layer',
  623. type: 'scene',
  624. url: layerConfig.dm2023H1Layer,
  625. visible: isShow,
  626. opacity: opacity?opacity:1,
  627. token: ''
  628. })
  629. var data = {'distance': 100, 'year': 2023.1}
  630. if(isShow){
  631. if(getMapScale() <= 5000) {
  632. getDeepthPoints(data)
  633. }
  634. }else{
  635. clearMap({is_draw: true, is_search:true, layers: []})
  636. }
  637. setDepthState(data,isShow)
  638. break*/
  639. case 'pm_2023.2':
  640. addLayer({
  641. id: 'warterDepthLine2023H2Layer',
  642. title: 'warterDepthLine2023H2Layer',
  643. type: 'scene',
  644. url: layerConfig.dm2023H2Layer,
  645. visible: isShow,
  646. opacity: opacity?opacity:1,
  647. token: ''
  648. })
  649. var data = {'distance': 100, 'year': 2023.2}
  650. if(isShow){
  651. if(getMapScale() <= 5000) {
  652. getDeepthPoints(data)
  653. }
  654. }else{
  655. clearMap({is_draw: true, is_search:true, layers: []})
  656. }
  657. setDepthState(data,isShow)
  658. break
  659. }
  660. }
  661. export function refreshDepthPoints(){
  662. if(getMapScale() <= 5000 && showDepthPoints) {
  663. getDeepthPoints(depthParams)
  664. }else{
  665. clearMap({is_draw: false, is_search:true, layers: []})
  666. }
  667. }
  668. function getDeepthPoints(data){
  669. // if(data != null && data.year === currentDepthYear){
  670. // return
  671. // }
  672. // currentDepthYear = data.year
  673. let extent = getMapExtent()
  674. data.maxX = extent.xmax + 200
  675. data.minX = extent.xmin - 200
  676. data.maxY = extent.ymax + 200
  677. data.minY = extent.ymin - 200
  678. GetHpjDepthPoints(data).then(res=>{
  679. if(res.code == '200'){
  680. if(res.data.Rows != null && res.data.Rows.length > 0){
  681. let rows = res.data.Rows
  682. let dataList = []
  683. for(let i=0;i<rows.length;i++){
  684. let linePoints = rows[i]
  685. if(linePoints.length > 0){
  686. for(let j=0;j<linePoints.length;j++){
  687. if(linePoints[j].depth == null){
  688. continue
  689. }
  690. let point = {
  691. x: linePoints[j].pointX,
  692. y: linePoints[j].pointY,
  693. z: linePoints[j].pointZ * 10,
  694. text: linePoints[j].depth
  695. }
  696. dataList.push(point)
  697. }
  698. }
  699. }
  700. addGraphic({
  701. "type": 'points',
  702. "is_edit": false,
  703. "is_clear": true,
  704. "is_temp": false,
  705. "is_goto": false,
  706. "data": dataList,
  707. "attributes": null,
  708. "symbol": {
  709. type: "simple-marker",
  710. style: "circle",
  711. color: [255, 255, 255],
  712. size: 5
  713. },
  714. "title": null
  715. })
  716. }else{
  717. this.$message({
  718. type: 'error',
  719. message: '未查询到水深点数据!'
  720. })
  721. }
  722. }else{
  723. this.$message({
  724. type: 'error',
  725. message: '查询水深点数据失败!'
  726. })
  727. console.log(res.msg)
  728. }
  729. })
  730. }
  731. function setDepthState(data,state){
  732. setShowDepthPointsState(state)
  733. showDepthPoints = state
  734. if(state){
  735. depthParams = data
  736. }
  737. else{
  738. depthParams = null
  739. }
  740. }