ef737571ba4dea50303c1918c47821a2afbf58a9.svn-base 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. import {getShgcListForMap,getBaseList} from '../../../api/zhxxAPI.js'
  2. import {removeLayerById} from './removeLayerById.js'
  3. import { mapConfig } from '../config/mapConfig.js';
  4. export function getSzy_syd(_self){
  5. var ol = _self.$ol;
  6. removeLayerById(_self,'szy_sydGraphicLayer0');
  7. removeLayerById(_self,'szy_sydGraphicLayer1');
  8. removeLayerById(_self,'szy_sydGraphicLayer2');
  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/syd0.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/syd2.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/syd1.png'
  28. // }))
  29. // });
  30. var symbol,iconFeature;
  31. var features0 = [];
  32. var features1 = [];
  33. var features2 = [];
  34. getShgcListForMap(_self.userId,'17',_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'] = 'szy_sydGraphicLayer1';
  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/syd2.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'] = 'szy_sydGraphicLayer2';
  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/syd1.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'] = 'szy_sydGraphicLayer0';
  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/syd0.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:'szy_sydGraphicLayer0',
  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:'szy_sydGraphicLayer1',
  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:'szy_sydGraphicLayer2',
  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 getSzy_allSyd(_self){
  171. var ol = _self.$ol;
  172. removeLayerById(_self,'szy_allSydGraphicLayer');
  173. var symbol,iconFeature;
  174. var features = [];
  175. var displayLevel = _self.mapObject.getView().getZoom()-3;
  176. getBaseList('13',displayLevel).then((res)=>{
  177. if(res.data){
  178. res.data.forEach((item)=>{
  179. if(item.pcX && item.pcY){
  180. // var pt = ol.proj.transform([Number(item.pcX), Number(item.pcY)], "EPSG:4326", "EPSG:3857")
  181. var pt = _self.projTransform(new ol.geom.Point([Number(item.pcX), Number(item.pcY)]),mapConfig.wkid)
  182. iconFeature = new ol.Feature({
  183. geometry: pt,
  184. name: '水资源全部水源地'
  185. });
  186. item['layerId'] = 'szy_allSydGraphicLayer';
  187. iconFeature.setProperties(item);
  188. var symbol = new ol.style.Style({//
  189. image: new ol.style.Icon({
  190. anchor: [0.5, 0.5],
  191. scale:0.4,
  192. src: '/src/views/zongHeXinXiOl/assets/syd.png'
  193. }),
  194. text: new ol.style.Text({
  195. font: 'normal 14px 黑体',
  196. // // 对其方式
  197. textAlign: 'center',
  198. // 基准线
  199. textBaseline: 'middle',
  200. offsetY: -15,
  201. offsetX: 0,
  202. fill: new ol.style.Fill({
  203. color: 'white'
  204. }),
  205. stroke: new ol.style.Stroke({
  206. color: 'black',
  207. lineCap: 'butt',
  208. width: 4
  209. }),
  210. padding: [5, 5, 5, 5],
  211. text: item.nm
  212. })
  213. });
  214. iconFeature.setStyle(symbol);
  215. features.push(iconFeature)
  216. }
  217. });
  218. var vectorSource = new ol.source.Vector({
  219. features: features
  220. });
  221. var vectorLayer = new ol.layer.Vector({
  222. source: vectorSource,
  223. id:'szy_allSydGraphicLayer',
  224. visible:true
  225. });
  226. _self.mapObject.addLayer(vectorLayer)
  227. }
  228. })
  229. }