3612d324d40a470e3cf086be806d8d1c79b4e10a.svn-base 7.2 KB

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