0e0f31d27b5cf18c70e38bae1912dfe6cc195d0b.svn-base 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. import {getShgcListForMap} from '../../../api/zhxxAPI.js'
  2. import {removeLayerById} from './removeLayerById.js'
  3. import { mapConfig } from '../config/mapConfig.js';
  4. export function getShList(_self){
  5. var ol = _self.$ol;
  6. removeLayerById(_self,'shgcGraphicLayer0');
  7. removeLayerById(_self,'shgcGraphicLayer1');
  8. removeLayerById(_self,'shgcGraphicLayer2');
  9. // var symbol0 = new ol.style.Style({//未修复 0
  10. // image: new ol.style.Icon(({
  11. // anchor: [0.5, 0.5],
  12. // scale:0.4,
  13. // src: '/src/views/zongHeXinXiOl/assets/shuihui0.png'
  14. // }))
  15. // });
  16. // var symbol1 = new ol.style.Style({//已修复 1
  17. // image: new ol.style.Icon(({
  18. // anchor: [0.5, 0.5],
  19. // scale:0.4,
  20. // src: '/src/views/zongHeXinXiOl/assets/shuihui2.png'
  21. // }))
  22. // });
  23. // var symbol2 = new ol.style.Style({//2修复中
  24. // image: new ol.style.Icon(({
  25. // anchor: [0.5, 0.5],
  26. // scale:0.4,
  27. // src: '/src/views/zongHeXinXiOl/assets/shuihui1.png'
  28. // }))
  29. // });
  30. var symbol,iconFeature;
  31. var features0 = [];
  32. var features1 = [];
  33. var features2 = [];
  34. getShgcListForMap(_self.userId,'3',_self.currentAdCode).then((res)=>{
  35. if(res.data){
  36. res.data.forEach((item)=>{
  37. if(item.lgtd && item.lttd){
  38. // var pt = ol.proj.transform([item.lgtd, item.lttd], "EPSG:4326", "EPSG:3857")
  39. var pt = _self.projTransform(new ol.geom.Point([Number(item.lgtd), Number(item.lttd)]),mapConfig.wkid)
  40. iconFeature = new ol.Feature({
  41. geometry: pt,
  42. name: '水毁工程'
  43. });
  44. if(item.state == "1"){
  45. item['layerId'] = 'shgcGraphicLayer1';
  46. iconFeature.setProperties(item);
  47. symbol = new ol.style.Style({
  48. image: new ol.style.Icon({
  49. anchor: [0.5, 0.5],
  50. scale:0.4,
  51. src: "/src/views/zongHeXinXiOl/assets/shuihui2.png"
  52. }),
  53. text: new ol.style.Text({
  54. font: 'normal 14px 黑体',
  55. // // 对其方式
  56. textAlign: 'center',
  57. // 基准线
  58. textBaseline: 'middle',
  59. offsetY: -15,
  60. offsetX: 0,
  61. fill: new ol.style.Fill({
  62. color: 'white'
  63. }),
  64. stroke: new ol.style.Stroke({
  65. color: 'black',
  66. lineCap: 'butt',
  67. width: 4
  68. }),
  69. padding: [5, 5, 5, 5],
  70. text: item.wtdstNm,
  71. })
  72. });
  73. iconFeature.setStyle(symbol);
  74. features1.push(iconFeature)
  75. }else if(item.state == "2"){
  76. item['layerId'] = 'shgcGraphicLayer2';
  77. iconFeature.setProperties(item);
  78. symbol = new ol.style.Style({
  79. image: new ol.style.Icon({
  80. anchor: [0.5, 0.5],
  81. scale:0.4,
  82. src: "/src/views/zongHeXinXiOl/assets/shuihui1.png"
  83. }),
  84. text: new ol.style.Text({
  85. font: 'normal 14px 黑体',
  86. // // 对其方式
  87. textAlign: 'center',
  88. // 基准线
  89. textBaseline: 'middle',
  90. offsetY: -15,
  91. offsetX: 0,
  92. fill: new ol.style.Fill({
  93. color: 'white'
  94. }),
  95. stroke: new ol.style.Stroke({
  96. color: 'black',
  97. lineCap: 'butt',
  98. width: 4
  99. }),
  100. padding: [5, 5, 5, 5],
  101. text: item.wtdstNm,
  102. })
  103. });
  104. iconFeature.setStyle(symbol);
  105. features2.push(iconFeature)
  106. }else{
  107. item['layerId'] = 'shgcGraphicLayer0';
  108. iconFeature.setProperties(item);
  109. symbol = new ol.style.Style({
  110. image: new ol.style.Icon({
  111. anchor: [0.5, 0.5],
  112. scale:0.4,
  113. src: "/src/views/zongHeXinXiOl/assets/shuihui0.png"
  114. }),
  115. text: new ol.style.Text({
  116. font: 'normal 14px 黑体',
  117. // // 对其方式
  118. textAlign: 'center',
  119. // 基准线
  120. textBaseline: 'middle',
  121. offsetY: -15,
  122. offsetX: 0,
  123. fill: new ol.style.Fill({
  124. color: 'white'
  125. }),
  126. stroke: new ol.style.Stroke({
  127. color: 'black',
  128. lineCap: 'butt',
  129. width: 4
  130. }),
  131. padding: [5, 5, 5, 5],
  132. text: item.wtdstNm
  133. })
  134. });
  135. iconFeature.setStyle(symbol);
  136. features0.push(iconFeature)
  137. }
  138. }
  139. });
  140. var vectorSource0 = new ol.source.Vector({
  141. features: features0
  142. });
  143. var vectorLayer0 = new ol.layer.Vector({
  144. source: vectorSource0,
  145. id:'shgcGraphicLayer0',
  146. visible:true
  147. });
  148. var vectorSource1 = new ol.source.Vector({
  149. features: features1
  150. });
  151. var vectorLayer1 = new ol.layer.Vector({
  152. source: vectorSource1,
  153. id:'shgcGraphicLayer1',
  154. visible:true
  155. });
  156. var vectorSource2 = new ol.source.Vector({
  157. features: features2
  158. });
  159. var vectorLayer2 = new ol.layer.Vector({
  160. source: vectorSource2,
  161. id:'shgcGraphicLayer2',
  162. visible:true
  163. });
  164. _self.mapObject.addLayer(vectorLayer0)
  165. _self.mapObject.addLayer(vectorLayer1)
  166. _self.mapObject.addLayer(vectorLayer2)
  167. }
  168. })
  169. }