e5d7d7d08c4e29d4b63b3d012e1245777ac5468d.svn-base 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. import {getShgcListForMap,getBaseList} from '../../../api/zhxxAPI.js'
  2. import {removeLayerById} from './removeLayerById.js'
  3. import { mapConfig } from '../config/mapConfig.js';
  4. export function getYdbList(_self){
  5. var ol = _self.$ol;
  6. removeLayerById(_self,'ydbGraphicLayer0');
  7. removeLayerById(_self,'ydbGraphicLayer1');
  8. removeLayerById(_self,'ydbGraphicLayer2');
  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/ydb0.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/ydb1.png'
  21. // }))
  22. // });
  23. // var symbol2 = new ol.style.Style({//已督查
  24. // image: new ol.style.Icon(({
  25. // anchor: [0.5, 0.5],
  26. // scale:0.4,
  27. // src: '/src/views/zongHeXinXiOl/assets/ydb2.png'
  28. // }))
  29. // });
  30. var symbol,iconFeature;
  31. var features0 = [];
  32. var features1 = [];
  33. var features2 = [];
  34. getShgcListForMap(_self.userId,'11',_self.currentAdCode).then((res)=>{
  35. if(res.data){
  36. res.data.forEach((item)=>{
  37. if(item.centerX && item.centerY){
  38. // var pt = ol.proj.transform([item.centerX, item.centerY], "EPSG:4326", "EPSG:3857")
  39. var pt = _self.projTransform(new ol.geom.Point([Number(item.centerX), Number(item.centerY)]),mapConfig.wkid)
  40. iconFeature = new ol.Feature({
  41. geometry: pt,
  42. name: '淤地坝'
  43. });
  44. if(item.state == "1"){
  45. item['layerId'] = 'ydbGraphicLayer1';
  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/ydb1.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.nm
  71. })
  72. });
  73. iconFeature.setStyle(symbol);
  74. features1.push(iconFeature)
  75. }else if(item.state == "2"){
  76. item['layerId'] = 'ydbGraphicLayer2';
  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/ydb2.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.nm
  102. })
  103. });
  104. iconFeature.setStyle(symbol);
  105. features2.push(iconFeature)
  106. }else{
  107. item['layerId'] = 'ydbGraphicLayer0';
  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/ydb0.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.nm
  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:'ydbGraphicLayer0',
  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:'ydbGraphicLayer1',
  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:'ydbGraphicLayer2',
  162. visible:true
  163. });
  164. _self.mapObject.addLayer(vectorLayer0)
  165. _self.mapObject.addLayer(vectorLayer1)
  166. _self.mapObject.addLayer(vectorLayer2)
  167. }
  168. })
  169. }
  170. export function getAllYdbList(_self){
  171. var ol = _self.$ol;
  172. removeLayerById(_self,'allYdbGraphicLayer');
  173. var iconFeature;
  174. var features = [];
  175. getBaseList('11').then((res)=>{
  176. if(res.data){
  177. res.data.forEach((item)=>{
  178. if(item.pcX && item.pcY){
  179. // var pt = ol.proj.transform([Number(item.pcX), Number(item.pcY)], "EPSG:4326", "EPSG:3857")
  180. var pt = _self.projTransform(new ol.geom.Point([Number(item.pcX), Number(item.pcY)]),mapConfig.wkid)
  181. iconFeature = new ol.Feature({
  182. geometry: pt,
  183. name: '全部淤地坝'
  184. });
  185. item['layerId'] = 'allYdbGraphicLayer';
  186. iconFeature.setProperties(item);
  187. var symbol = new ol.style.Style({//已督查
  188. image: new ol.style.Icon({
  189. anchor: [0.5, 0.5],
  190. scale:0.4,
  191. src: '/src/views/zongHeXinXiOl/assets/ydb2.png'
  192. }),
  193. text: new ol.style.Text({
  194. font: 'normal 14px 黑体',
  195. // // 对其方式
  196. textAlign: 'center',
  197. // 基准线
  198. textBaseline: 'middle',
  199. offsetY: -15,
  200. offsetX: 0,
  201. fill: new ol.style.Fill({
  202. color: 'white'
  203. }),
  204. stroke: new ol.style.Stroke({
  205. color: 'black',
  206. lineCap: 'butt',
  207. width: 4
  208. }),
  209. padding: [5, 5, 5, 5],
  210. text: item.nm
  211. })
  212. });
  213. iconFeature.setStyle(symbol);
  214. features.push(iconFeature)
  215. }
  216. });
  217. var vectorSource = new ol.source.Vector({
  218. features: features
  219. });
  220. var vectorLayer = new ol.layer.Vector({
  221. source: vectorSource,
  222. id:'allYdbGraphicLayer',
  223. visible:true
  224. });
  225. _self.mapObject.addLayer(vectorLayer)
  226. }
  227. })
  228. }