b5da0b0729ed44ee7b301a9ead1e0dd9cd1f70db.svn-base 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833
  1. import axios from 'axios'
  2. import {_longLatTransform} from './mercatorToLngLat'
  3. import { mapConfig } from '../config/mapConfig.js';
  4. let cancelRequest;
  5. var cancelToken = new axios.CancelToken(function executor(c) {
  6. cancelRequest = c
  7. console.log(c)
  8. // 这个参数 c 就是CancelToken构造函数里面自带的取消请求的函数,这里把该函数当参数用
  9. });
  10. var totCap = '';
  11. var totCapWidthZoom = [
  12. {
  13. zoom:0,
  14. totCap:750,
  15. },{
  16. zoom:1,
  17. totCap:750,
  18. },{
  19. zoom:2,
  20. totCap:750,
  21. },{
  22. zoom:3,
  23. totCap:750,
  24. },{
  25. zoom:4,
  26. totCap:750,
  27. },{
  28. zoom:5,
  29. totCap:750,
  30. },{
  31. zoom:6,
  32. totCap:750,
  33. },{
  34. zoom:7,
  35. totCap:300,
  36. },{
  37. zoom:8,
  38. totCap:100,
  39. },{
  40. zoom:9,
  41. totCap:'',
  42. },{
  43. zoom:10,
  44. totCap:'',
  45. },{
  46. zoom:11,
  47. totCap:'',
  48. },{
  49. zoom:12,
  50. totCap:'',
  51. },{
  52. zoom:13,
  53. totCap:'',
  54. },{
  55. zoom:14,
  56. totCap:'',
  57. },{
  58. zoom:15,
  59. totCap:'',
  60. },{
  61. zoom:16,
  62. totCap:'',
  63. },{
  64. zoom:17,
  65. totCap:'',
  66. },{
  67. zoom:18,
  68. totCap:'',
  69. }
  70. ]
  71. import {getSkList,getXgxdBaseList,getPblmByDcType} from '../../../api/zhxxAPI.js'
  72. import {removeLayerById,getShowOrFalse} from './removeLayerById.js'
  73. import {getShgcListForMap} from "../../../api/zhxxAPI";
  74. export function initXgxdBaseData(_self){
  75. var ol = _self.$ol;
  76. removeLayerById(_self,'xgxdBaseGraphicLayer');
  77. totCapWidthZoom.forEach((item)=>{
  78. if(item.zoom == _self.mapObject.getView().getZoom()){
  79. totCap = item.totCap;
  80. }
  81. });
  82. var maxLgtd = _self.mapObject.getView().calculateExtent()[2];
  83. var maxLttd = _self.mapObject.getView().calculateExtent()[3];
  84. var minLgtd = _self.mapObject.getView().calculateExtent()[0];
  85. var minLttd = _self.mapObject.getView().calculateExtent()[1];
  86. var bottomLeft = _longLatTransform({
  87. x:minLgtd,
  88. y:minLttd
  89. })
  90. var topRight = _longLatTransform({
  91. x:maxLgtd,
  92. y:maxLttd
  93. })
  94. var maxLgtd1 = topRight.x;
  95. var maxLttd1 = topRight.y;
  96. var minLgtd1 = bottomLeft.x;
  97. var minLttd1 = bottomLeft.y;
  98. var obj = {
  99. "persGuid":_self.userId,
  100. "adCode": _self.currentAdCode,
  101. "count": true,
  102. "engScal": "",
  103. "fields": "",
  104. "maxLgtd": maxLgtd1,
  105. "maxLttd": maxLttd1,
  106. "minLgtd": minLgtd1,
  107. "minLttd": minLttd1,
  108. "offset": "",
  109. "orderBy": "",
  110. "pageNum": 0,
  111. "pageSize": 0,
  112. "rsName": "",
  113. "status": "",
  114. "objType":"291",
  115. // "totCap": totCap
  116. "displayLevel":_self.mapObject.getView().getZoom()-3
  117. };
  118. cancelRequest;
  119. var symbol = new ol.style.Style({
  120. image: new ol.style.Icon(({
  121. anchor: [0.5, 0.5],
  122. scale:0.4,
  123. src: '/src/views/zongHeXinXiOl/assets/shuiku_All.png'
  124. }))
  125. });
  126. getXgxdBaseList(obj.persGuid,obj.adCode,obj.objType).then((res)=>{
  127. res.data.list = res.data;
  128. if(res.data && res.data.length>0){
  129. res.data.list.forEach((item,index) =>{
  130. item.longitude = item.centerX;
  131. item.latitude = item.centerY;
  132. });
  133. addFeaturesToMap(res,_self,'险工险段基础信息','xgxdBaseGraphicLayer',symbol,true)
  134. }
  135. })
  136. }
  137. export function initXgxdDcData(_self){
  138. var ol = _self.$ol;
  139. removeLayerById(_self,'xgxdDcGraphicLayer');
  140. totCapWidthZoom.forEach((item)=>{
  141. if(item.zoom == _self.mapObject.getView().getZoom()){
  142. totCap = item.totCap;
  143. }
  144. });
  145. var maxLgtd = _self.mapObject.getView().calculateExtent()[2];
  146. var maxLttd = _self.mapObject.getView().calculateExtent()[3];
  147. var minLgtd = _self.mapObject.getView().calculateExtent()[0];
  148. var minLttd = _self.mapObject.getView().calculateExtent()[1];
  149. var bottomLeft = _longLatTransform({
  150. x:minLgtd,
  151. y:minLttd
  152. })
  153. var topRight = _longLatTransform({
  154. x:maxLgtd,
  155. y:maxLttd
  156. })
  157. var maxLgtd1 = topRight.x;
  158. var maxLttd1 = topRight.y;
  159. var minLgtd1 = bottomLeft.x;
  160. var minLttd1 = bottomLeft.y;
  161. var obj = {
  162. "persGuid":_self.userId,
  163. "adCode": _self.currentAdCode,
  164. "count": true,
  165. "engScal": "",
  166. "fields": "",
  167. "maxLgtd": maxLgtd1,
  168. "maxLttd": maxLttd1,
  169. "minLgtd": minLgtd1,
  170. "minLttd": minLttd1,
  171. "offset": "",
  172. "orderBy": "",
  173. "pageNum": 0,
  174. "pageSize": 0,
  175. "rsName": "",
  176. "status": "",
  177. "objType":"292",
  178. // "totCap": totCap
  179. "displayLevel":_self.mapObject.getView().getZoom()-3
  180. };
  181. cancelRequest;
  182. var symbol = new ol.style.Style({
  183. image: new ol.style.Icon(({
  184. anchor: [0.5, 0.5],
  185. scale:0.4,
  186. src: '/src/views/zongHeXinXiOl/assets/shuiku_All.png'
  187. }))
  188. });
  189. getXgxdBaseList(obj.persGuid,obj.adCode,obj.objType).then((res)=>{
  190. res.data.list = res.data;
  191. if(res.data && res.data.length>0){
  192. res.data.list.forEach((item,index) =>{
  193. item.longitude = item.centerX;
  194. item.latitude = item.centerY;
  195. });
  196. addFeaturesToMap(res,_self,'险工险段督查信息','xgxdDcGraphicLayer',symbol,true)
  197. }
  198. })
  199. }
  200. export function initAllSkData(_self,type){
  201. var ol = _self.$ol;
  202. var show0 = true;
  203. var show1 = true;
  204. var show2 = true;
  205. if(type==1){
  206. show0 = getShowOrFalse(_self,"allSkGraphicLayer0");
  207. show1 = getShowOrFalse(_self,"allSkGraphicLayer1");
  208. show2 = getShowOrFalse(_self,"allSkGraphicLayer2");
  209. }
  210. removeLayerById(_self,'allSkGraphicLayer0');
  211. removeLayerById(_self,'allSkGraphicLayer1');
  212. removeLayerById(_self,'allSkGraphicLayer2');
  213. totCapWidthZoom.forEach((item)=>{
  214. if(item.zoom == _self.mapObject.getView().getZoom()){
  215. totCap = item.totCap;
  216. }
  217. });
  218. var maxLgtd = _self.mapObject.getView().calculateExtent()[2];
  219. var maxLttd = _self.mapObject.getView().calculateExtent()[3];
  220. var minLgtd = _self.mapObject.getView().calculateExtent()[0];
  221. var minLttd = _self.mapObject.getView().calculateExtent()[1];
  222. var bottomLeft = _longLatTransform({
  223. x:minLgtd,
  224. y:minLttd
  225. })
  226. var topRight = _longLatTransform({
  227. x:maxLgtd,
  228. y:maxLttd
  229. })
  230. var maxLgtd1 = topRight.x;
  231. var maxLttd1 = topRight.y;
  232. var minLgtd1 = bottomLeft.x;
  233. var minLttd1 = bottomLeft.y;
  234. var obj = {
  235. "persGuid":_self.userId,
  236. "adCode": _self.currentAdCode,
  237. "count": true,
  238. "engScal": "",
  239. "fields": "",
  240. "maxLgtd": maxLgtd1,
  241. "maxLttd": maxLttd1,
  242. "minLgtd": minLgtd1,
  243. "minLttd": minLttd1,
  244. "offset": "",
  245. "orderBy": "",
  246. "pageNum": 0,
  247. "pageSize": 0,
  248. "rsName": "",
  249. "status": "",
  250. // "totCap": totCap
  251. "displayLevel":_self.mapObject.getView().getZoom()-3
  252. };
  253. cancelRequest;
  254. // var symbol = new ol.style.Style({
  255. // image: new ol.style.Icon(({
  256. // anchor: [0.5, 0.5],
  257. // scale:0.4,
  258. // src: '/src/views/zongHeXinXiOl/assets/shuiku_All.png'
  259. // }))
  260. // });
  261. var src = "/src/views/zongHeXinXiOl/assets/shuiku_All.png"
  262. var propertyNm = "rsName";
  263. getSkList(obj).then((res)=>{
  264. addFeaturesToMap(res,_self,'水库','allSkGraphicLayer',src,true,propertyNm,show0,show1,show2)
  265. })
  266. }
  267. export function init2018SkData(_self){//2018水库
  268. var ol = _self.$ol;
  269. removeLayerById(_self,'skGraphicLayer2018');
  270. totCapWidthZoom.forEach((item)=>{
  271. if(item.zoom == _self.mapObject.getView().getZoom()){
  272. totCap = item.totCap;
  273. }
  274. });
  275. var maxLgtd = _self.mapObject.getView().calculateExtent()[2];
  276. var maxLttd = _self.mapObject.getView().calculateExtent()[3];
  277. var minLgtd = _self.mapObject.getView().calculateExtent()[0];
  278. var minLttd = _self.mapObject.getView().calculateExtent()[1];
  279. var bottomLeft = _longLatTransform({
  280. x:minLgtd,
  281. y:minLttd
  282. })
  283. var topRight = _longLatTransform({
  284. x:maxLgtd,
  285. y:maxLttd
  286. })
  287. var maxLgtd1 = topRight.x;
  288. var maxLttd1 = topRight.y;
  289. var minLgtd1 = bottomLeft.x;
  290. var minLttd1 = bottomLeft.y;
  291. var obj = {
  292. "persGuid":_self.userId,
  293. "adCode": _self.currentAdCode,
  294. "count": true,
  295. "engScal": "",
  296. "fields": "",
  297. "maxLgtd": maxLgtd1,
  298. "maxLttd": maxLttd1,
  299. "minLgtd": minLgtd1,
  300. "minLttd": minLttd1,
  301. "offset": "",
  302. "orderBy": "",
  303. "pageNum": 0,
  304. "pageSize": 0,
  305. "rsName": "",
  306. "status": "1",
  307. "totCap": totCap,
  308. // "displayLevel":_self.mapObject.getView().getZoom()-3
  309. };
  310. // var symbol = new ol.style.Style({
  311. // image: new ol.style.Icon(({
  312. // anchor: [0.5, 0.5],
  313. // scale:0.4,
  314. // src: '/src/views/zongHeXinXiOl/assets/shuiku_2018.png'
  315. // }))
  316. // });
  317. var src = "/src/views/zongHeXinXiOl/assets/shuiku_2018.png"
  318. var propertyNm = "rsName"
  319. getSkList(obj).then((res)=>{
  320. addFeaturesToMap(res,_self,'2018督查水库','skGraphicLayer2018',src,true,propertyNm)
  321. })
  322. }
  323. export function init2019SkData(_self){//2019年
  324. var ol = _self.$ol;
  325. removeLayerById(_self,'skGraphicLayer20190');
  326. removeLayerById(_self,'skGraphicLayer20191');
  327. removeLayerById(_self,'skGraphicLayer20192');
  328. var maxLgtd = _self.mapObject.getView().calculateExtent()[2];
  329. var maxLttd = _self.mapObject.getView().calculateExtent()[3];
  330. var minLgtd = _self.mapObject.getView().calculateExtent()[0];
  331. var minLttd = _self.mapObject.getView().calculateExtent()[1];
  332. var bottomLeft = _longLatTransform({
  333. x:minLgtd,
  334. y:minLttd
  335. })
  336. var topRight = _longLatTransform({
  337. x:maxLgtd,
  338. y:maxLttd
  339. })
  340. var maxLgtd1 = topRight.x;
  341. var maxLttd1 = topRight.y;
  342. var minLgtd1 = bottomLeft.x;
  343. var minLttd1 = bottomLeft.y;
  344. var obj = {
  345. "persGuid":_self.userId,
  346. "adCode": _self.currentAdCode,
  347. "count": true,
  348. "engScal": "",
  349. "fields": "",
  350. "maxLgtd": '',
  351. "maxLttd": '',
  352. "minLgtd": '',
  353. "minLttd": '',
  354. "offset": "",
  355. "orderBy": "",
  356. "pageNum": 0,
  357. "pageSize": 0,
  358. "rsName": "",
  359. "status": "2",
  360. "totCap": 0
  361. };
  362. // var symbol0 = new ol.style.Style({//已督查
  363. // image: new ol.style.Icon(({
  364. // anchor: [0.5, 0.5],
  365. // scale:0.4,
  366. // src: '/src/views/zongHeXinXiOl/assets/shuiku0.png'
  367. // }))
  368. // });
  369. // var symbol1 = new ol.style.Style({//督查中
  370. // image: new ol.style.Icon(({
  371. // anchor: [0.5, 0.5],
  372. // scale:0.4,
  373. // src: '/src/views/zongHeXinXiOl/assets/shuiku1.png'
  374. // }))
  375. // });
  376. // var symbol2 = new ol.style.Style({//未督查
  377. // image: new ol.style.Icon(({
  378. // anchor: [0.5, 0.5],
  379. // scale:0.4,
  380. // src: '/src/views/zongHeXinXiOl/assets/shuiku2.png'
  381. // }))
  382. // });
  383. var src0 = "/src/views/zongHeXinXiOl/assets/shuiku0.png"
  384. var src1 = "/src/views/zongHeXinXiOl/assets/shuiku1.png"
  385. var src2 = "/src/views/zongHeXinXiOl/assets/shuiku2.png"
  386. var propertyNm = "rsName"
  387. getSkList(obj).then((res)=>{
  388. addFeaturesToMap0(res,_self,'2019督查水库','skGraphicLayer2019',src0,src1,src2,true,propertyNm);
  389. })
  390. }
  391. export function initFcSkData(_self){
  392. var ol = _self.$ol;
  393. removeLayerById(_self,'fcskGraphicLayer0');
  394. removeLayerById(_self,'fcskGraphicLayer1');
  395. removeLayerById(_self,'fcskGraphicLayer2');
  396. var obj = {
  397. "persGuid":_self.userId,
  398. "adCode": _self.currentAdCode,
  399. "count": true,
  400. "engScal": "",
  401. "fields": "",
  402. "maxLgtd": '',
  403. "maxLttd": '',
  404. "minLgtd": '',
  405. "minLttd": '',
  406. "offset": "",
  407. "orderBy": "",
  408. "pageNum": 0,
  409. "pageSize": 0,
  410. "rsName": "",
  411. "status": "3",
  412. "totCap": 0
  413. };
  414. // var symbol0 = new ol.style.Style({//已督查
  415. // image: new ol.style.Icon(({
  416. // anchor: [0.5, 0.5],
  417. // scale:0.4,
  418. // src: '/src/views/zongHeXinXiOl/assets/shuiku0.png'
  419. // }))
  420. // });
  421. // var symbol1 = new ol.style.Style({//督查中
  422. // image: new ol.style.Icon(({
  423. // anchor: [0.5, 0.5],
  424. // scale:0.4,
  425. // src: '/src/views/zongHeXinXiOl/assets/shuiku1.png'
  426. // }))
  427. // });
  428. // var symbol2 = new ol.style.Style({//未督查
  429. // image: new ol.style.Icon(({
  430. // anchor: [0.5, 0.5],
  431. // scale:0.4,
  432. // src: '/src/views/zongHeXinXiOl/assets/shuiku2.png'
  433. // }))
  434. // });
  435. var src0 = "/src/views/zongHeXinXiOl/assets/shuiku0.png"
  436. var src1 = "/src/views/zongHeXinXiOl/assets/shuiku1.png"
  437. var src2 = "/src/views/zongHeXinXiOl/assets/shuiku2.png"
  438. var propertyNm = "rsName";
  439. getSkList(obj).then((res)=>{
  440. addFeaturesToMap0(res,_self,'复查水库','fcskGraphicLayer',src0,src1,src2,true,propertyNm);
  441. })
  442. }
  443. export function initJhwSkData(_self){
  444. var ol = _self.$ol;
  445. removeLayerById(_self,'jhwskGraphicLayer');
  446. totCapWidthZoom.forEach((item)=>{
  447. if(item.zoom == _self.mapObject.getView().getZoom()){
  448. totCap = item.totCap;
  449. }
  450. });
  451. var maxLgtd = _self.mapObject.getView().calculateExtent()[2];
  452. var maxLttd = _self.mapObject.getView().calculateExtent()[3];
  453. var minLgtd = _self.mapObject.getView().calculateExtent()[0];
  454. var minLttd = _self.mapObject.getView().calculateExtent()[1];
  455. var bottomLeft = _longLatTransform({
  456. x:minLgtd,
  457. y:minLttd
  458. })
  459. var topRight = _longLatTransform({
  460. x:maxLgtd,
  461. y:maxLttd
  462. })
  463. var maxLgtd1 = topRight.x;
  464. var maxLttd1 = topRight.y;
  465. var minLgtd1 = bottomLeft.x;
  466. var minLttd1 = bottomLeft.y;
  467. var obj = {
  468. "persGuid":_self.userId,
  469. "adCode": _self.currentAdCode,
  470. "count": true,
  471. "engScal": "",
  472. "fields": "",
  473. "maxLgtd": maxLgtd1,
  474. "maxLttd": maxLttd1,
  475. "minLgtd": minLgtd1,
  476. "minLttd": minLttd1,
  477. "offset": "",
  478. "orderBy": "",
  479. "pageNum": 0,
  480. "pageSize": 0,
  481. "rsName": "",
  482. "status": "4",
  483. // "totCap": totCap
  484. "displayLevel":_self.mapObject.getView().getZoom()-3
  485. };
  486. // var symbol = new ol.style.Style({
  487. // image: new ol.style.Icon(({
  488. // anchor: [0.5, 0.5],
  489. // scale:0.4,
  490. // src: '/src/views/zongHeXinXiOl/assets/shuiku_jhw.png'
  491. // }))
  492. // });
  493. var src = "/src/views/zongHeXinXiOl/assets/shuiku_jhw.png"
  494. var propertyNm = "rsName"
  495. getSkList(obj).then((res)=>{
  496. addFeaturesToMap(res,_self,'督查计划外水库','jhwskGraphicLayer',src,true,propertyNm)
  497. })
  498. }
  499. export function initPblmDcData(_self,data) {
  500. //debugger
  501. var ol = _self.$ol;
  502. removeLayerById(_self,data.id);
  503. var iconFeature,vectorSource,vectorLayer;
  504. var features = [];
  505. getPblmByDcType(parseInt(data.code),data.startTime,data.endTime).then((res)=>{
  506. if(res.data && res.data.length>0){
  507. res.data.forEach((item)=>{
  508. if(item.pblmLong && item.pblmLat){
  509. // var pt = ol.proj.transform([item.lgtdPc, item.lttdPc], "EPSG:4326", "EPSG:3857")
  510. var pt = _self.projTransform(new ol.geom.Point([Number(item.pblmLong), Number(item.pblmLat)]),mapConfig.wkid)
  511. iconFeature = new ol.Feature({
  512. geometry: pt
  513. });
  514. item['layerId'] = data.id;
  515. iconFeature.setProperties(item);
  516. var symbol = new ol.style.Style({
  517. image: new ol.style.Icon({
  518. anchor: [0.5, 0.5],
  519. scale:0.4,
  520. src: '/src/views/zongHeXinXiOl/assets/pblm.png'
  521. }),
  522. text: new ol.style.Text({
  523. font: 'normal 12px 黑体',
  524. fontWeight:'bold',
  525. // // 对其方式
  526. textAlign: 'center',
  527. // 基准线
  528. textBaseline: 'middle',
  529. offsetY: -20,
  530. offsetX: 0,
  531. fill: new ol.style.Fill({
  532. color: 'black'
  533. }),
  534. stroke: new ol.style.Stroke({
  535. color: 'white',
  536. width: 2
  537. }),
  538. text: item.objName
  539. })
  540. });
  541. iconFeature.setStyle(symbol);
  542. features.push(iconFeature)
  543. }
  544. });
  545. vectorSource = new ol.source.Vector({
  546. features: features
  547. });
  548. vectorLayer = new ol.layer.Vector({
  549. source: vectorSource,
  550. id:data.id,
  551. visible:true
  552. });
  553. _self.mapObject.addLayer(vectorLayer)
  554. }
  555. })
  556. }
  557. function addFeaturesToMap(res,_self,name,id,src,visible,propertyNm,show0,show1,show2){
  558. var ol = _self.$ol;
  559. var iconFeature,vectorSource,vectorLayer,vectorSource1,vectorLayer1,vectorSource2,vectorLayer2;
  560. var features = [];
  561. var features1 = [];
  562. var features2 = [];
  563. cancelRequest;
  564. if(res.data.list){
  565. res.data.list.forEach((item)=>{
  566. if(item.latitude && item.longitude){
  567. // var pt = ol.proj.transform([item.longitude, item.latitude], "EPSG:4326", "EPSG:3857")
  568. var pt = _self.projTransform(new ol.geom.Point([Number(item.longitude), Number(item.latitude)]),mapConfig.wkid)
  569. iconFeature = new ol.Feature({
  570. geometry: pt,
  571. name: name
  572. });
  573. item['layerId'] = id;
  574. iconFeature.setProperties(item);
  575. if(id=="xgxdBaseGraphicLayer" || id=="xgxdDcGraphicLayer"){
  576. iconFeature.setStyle(new ol.style.Style({
  577. text: new ol.style.Text({
  578. font: '14px Microsoft YaHei',
  579. text: item[propertyNm],
  580. textAlign: "left",
  581. textBaseline: "middle",
  582. offsetX: 0,
  583. offsetY: -10,//调整相对位置
  584. fill: new ol.style.Fill({
  585. color: '#fff'
  586. }),
  587. stroke: new ol.style.Stroke({
  588. color: '#000000',
  589. width: 3
  590. })
  591. }),
  592. image: new ol.style.Circle({
  593. radius: 6,
  594. snapToPixel: false,
  595. fill: new ol.style.Fill({
  596. color:id=="xgxdBaseGraphicLayer"?'#f29b0d':'#CE0000'
  597. }),
  598. stroke: new ol.style.Stroke({
  599. color: id=="xgxdBaseGraphicLayer"?'#f2cb23':'#ce5957',
  600. width: 2
  601. })
  602. })
  603. }))
  604. features.push(iconFeature)
  605. }else{
  606. if(!item.status || item.status.indexOf('未')>-1 || item.status.indexOf('外')>-1){
  607. src = "/src/views/zongHeXinXiOl/assets/shuiku_jhw.png";
  608. item['layerId'] = 'allSkGraphicLayer0';
  609. }
  610. if(item.status.indexOf('中')>-1){
  611. src = "/src/views/zongHeXinXiOl/assets/shuiku2.png";
  612. item['layerId'] = 'allSkGraphicLayer1';
  613. }
  614. if(item.status.indexOf('已')>-1){
  615. src = "/src/views/zongHeXinXiOl/assets/shuiku_All.png";
  616. item['layerId'] = 'allSkGraphicLayer2';
  617. }
  618. var symbol1 = new ol.style.Style({
  619. image: new ol.style.Icon({
  620. anchor: [0.5, 0.5],
  621. scale:0.4,
  622. src: src
  623. }),
  624. text: new ol.style.Text({
  625. font: 'normal 14px 黑体',
  626. // // 对其方式
  627. textAlign: 'center',
  628. // 基准线
  629. textBaseline: 'middle',
  630. offsetY: -15,
  631. offsetX: 0,
  632. fill: new ol.style.Fill({
  633. color: 'white'
  634. }),
  635. stroke: new ol.style.Stroke({
  636. color: 'black',
  637. lineCap: 'butt',
  638. width: 4
  639. }),
  640. padding: [5, 5, 5, 5],
  641. text: item[propertyNm],
  642. })
  643. });
  644. iconFeature.setStyle(symbol1);
  645. iconFeature.setProperties(item);
  646. if(!item.rgstrStatus || item.rgstrStatus=="0"){
  647. features.push(iconFeature)
  648. }
  649. if(item.rgstrStatus=="1"){
  650. features1.push(iconFeature)
  651. }
  652. if(item.rgstrStatus=="2"){
  653. features2.push(iconFeature)
  654. }
  655. }
  656. }
  657. });
  658. vectorSource = new ol.source.Vector({
  659. features: features
  660. });
  661. vectorLayer = new ol.layer.Vector({
  662. source: vectorSource,
  663. id:"allSkGraphicLayer0",
  664. visible:show0
  665. });
  666. vectorSource1 = new ol.source.Vector({
  667. features: features1
  668. });
  669. vectorLayer1 = new ol.layer.Vector({
  670. source: vectorSource1,
  671. id:"allSkGraphicLayer1",
  672. visible:show1
  673. });
  674. vectorSource2 = new ol.source.Vector({
  675. features: features2
  676. });
  677. vectorLayer2 = new ol.layer.Vector({
  678. source: vectorSource2,
  679. id:"allSkGraphicLayer2",
  680. visible:show2
  681. });
  682. _self.mapObject.addLayer(vectorLayer)
  683. _self.mapObject.addLayer(vectorLayer1)
  684. _self.mapObject.addLayer(vectorLayer2)
  685. }
  686. }
  687. function addFeaturesToMap0(res,_self,name,id,src0,src1,src2,visible,propertyNm){
  688. var ol = _self.$ol;
  689. var symbol,iconFeature;
  690. var features0 = [];
  691. var features1 = [];
  692. var features2 = [];
  693. cancelRequest;
  694. if(res.data.list){
  695. res.data.list.forEach((item)=>{
  696. if(item.latitude && item.longitude){
  697. // var pt = ol.proj.transform([item.longitude, item.latitude], "EPSG:4326", "EPSG:3857")
  698. var pt = _self.projTransform(new ol.geom.Point([Number(item.longitude), Number(item.latitude)]),mapConfig.wkid)
  699. iconFeature = new ol.Feature({
  700. geometry: pt,
  701. name: name
  702. });
  703. if(item.rgstrStatus == '1'){//督查中
  704. item['layerId'] = id+'1';
  705. iconFeature.setProperties(item);
  706. symbol = new ol.style.Style({
  707. image: new ol.style.Icon({
  708. anchor: [0.5, 0.5],
  709. scale:0.4,
  710. src: src1
  711. }),
  712. text: new ol.style.Text({
  713. font: 'normal 14px 黑体',
  714. // // 对其方式
  715. textAlign: 'center',
  716. // 基准线
  717. textBaseline: 'middle',
  718. offsetY: -15,
  719. offsetX: 0,
  720. fill: new ol.style.Fill({
  721. color: 'white'
  722. }),
  723. stroke: new ol.style.Stroke({
  724. color: 'black',
  725. lineCap: 'butt',
  726. width: 4
  727. }),
  728. padding: [5, 5, 5, 5],
  729. text: item[propertyNm]
  730. })
  731. });
  732. iconFeature.setStyle(symbol);
  733. features1.push(iconFeature)
  734. }else if(item.rgstrStatus == '2'){//已督查
  735. item['layerId'] = id+'2';
  736. iconFeature.setProperties(item);
  737. symbol = new ol.style.Style({
  738. image: new ol.style.Icon({
  739. anchor: [0.5, 0.5],
  740. scale:0.4,
  741. src: src0
  742. }),
  743. text: new ol.style.Text({
  744. font: 'normal 14px 黑体',
  745. // // 对其方式
  746. textAlign: 'center',
  747. // 基准线
  748. textBaseline: 'middle',
  749. offsetY: -15,
  750. offsetX: 0,
  751. fill: new ol.style.Fill({
  752. color: 'white'
  753. }),
  754. stroke: new ol.style.Stroke({
  755. color: 'black',
  756. lineCap: 'butt',
  757. width: 4
  758. }),
  759. padding: [5, 5, 5, 5],
  760. text: item[propertyNm]
  761. })
  762. });
  763. iconFeature.setStyle(symbol);
  764. features2.push(iconFeature)
  765. }else{//未督查
  766. item['layerId'] = id+'0';
  767. iconFeature.setProperties(item);
  768. symbol = new ol.style.Style({
  769. image: new ol.style.Icon({
  770. anchor: [0.5, 0.5],
  771. scale:0.4,
  772. src: src2
  773. }),
  774. text: new ol.style.Text({
  775. font: 'normal 14px 黑体',
  776. // // 对其方式
  777. textAlign: 'center',
  778. // 基准线
  779. textBaseline: 'middle',
  780. offsetY: -15,
  781. offsetX: 0,
  782. fill: new ol.style.Fill({
  783. color: 'white'
  784. }),
  785. stroke: new ol.style.Stroke({
  786. color: 'black',
  787. lineCap: 'butt',
  788. width: 4
  789. }),
  790. padding: [5, 5, 5, 5],
  791. text: item[propertyNm]
  792. })
  793. });
  794. iconFeature.setStyle(symbol);
  795. features0.push(iconFeature)
  796. }
  797. }
  798. });
  799. var vectorSource0 = new ol.source.Vector({
  800. features: features0
  801. });
  802. var vectorLayer0 = new ol.layer.Vector({
  803. source: vectorSource0,
  804. id:id+'0',
  805. visible:visible
  806. });
  807. var vectorSource1 = new ol.source.Vector({
  808. features: features1
  809. });
  810. var vectorLayer1 = new ol.layer.Vector({
  811. source: vectorSource1,
  812. id:id+'1',
  813. visible:visible
  814. });
  815. var vectorSource2 = new ol.source.Vector({
  816. features: features2
  817. });
  818. var vectorLayer2 = new ol.layer.Vector({
  819. source: vectorSource2,
  820. id:id+'2',
  821. visible:visible
  822. });
  823. _self.mapObject.addLayer(vectorLayer0)
  824. _self.mapObject.addLayer(vectorLayer1)
  825. _self.mapObject.addLayer(vectorLayer2)
  826. }
  827. }