| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- import {getShgcListForMap} from '../../../api/zhxxAPI.js'
- import {removeLayerById} from './removeLayerById.js'
- import { mapConfig } from '../config/mapConfig.js';
- export function getSzy_jsgl(_self){//节水管理
- var ol = _self.$ol;
- removeLayerById(_self,'szy_jsglGraphicLayer0');
- removeLayerById(_self,'szy_jsglGraphicLayer1');
- removeLayerById(_self,'szy_jsglGraphicLayer2');
- // var symbol0 = new ol.style.Style({//未督查 0
- // // image: new ol.style.Circle({
- // // radius: 6,
- // // fill: new ol.style.Fill({
- // // color: 'red'
- // // })
- // // }),
- // image: new ol.style.Icon(({
- // anchor: [0.5, 0.5],
- // scale:0.4,
- // src: '/src/views/zongHeXinXiOl/assets/p2.png'
- // }))
- // });
- // var symbol1 = new ol.style.Style({//督查中 1
- // image: new ol.style.Icon(({
- // anchor: [0.5, 0.5],
- // scale:0.4,
- // src: '/src/views/zongHeXinXiOl/assets/p1.png'
- // }))
- // });
- // var symbol2 = new ol.style.Style({//已督查
- // image: new ol.style.Icon(({
- // anchor: [0.5, 0.5],
- // scale:0.4,
- // src: '/src/views/zongHeXinXiOl/assets/p0.png'
- // }))
- // });
- var symbol,iconFeature;
- var features0 = [];
- var features1 = [];
- var features2 = [];
- getShgcListForMap(_self.userId,'31',_self.currentAdCode).then((res)=>{
- if(res.data){
- res.data.forEach((item)=>{
- if(item.lgtd && item.lttd){
- // var pt = ol.proj.transform([item.lgtd, item.lttd], "EPSG:4326", "EPSG:3857")
- var pt = _self.projTransform(new ol.geom.Point([Number(item.lgtd), Number(item.lttd)]),mapConfig.wkid)
- iconFeature = new ol.Feature({
- geometry: pt,
- name: '水资源节水管理'
- });
- if(item.state == "1"){
- item['layerId'] = 'szy_jsglGraphicLayer1';
- iconFeature.setProperties(item);
- symbol = new ol.style.Style({
- image: new ol.style.Icon({
- anchor: [0.5, 0.5],
- scale:0.4,
- src: "/src/views/zongHeXinXiOl/assets/p1.png"
- }),
- text: new ol.style.Text({
- font: 'normal 14px 黑体',
- // // 对其方式
- textAlign: 'center',
- // 基准线
- textBaseline: 'middle',
- offsetY: -15,
- offsetX: 0,
- fill: new ol.style.Fill({
- color: 'white'
- }),
- stroke: new ol.style.Stroke({
- color: 'black',
- lineCap: 'butt',
- width: 4
- }),
- padding: [5, 5, 5, 5],
- text: item.nm
- })
- });
- iconFeature.setStyle(symbol);
- features1.push(iconFeature)
- }else if(item.state == "2"){
- item['layerId'] = 'szy_jsglGraphicLayer2';
- iconFeature.setProperties(item);
- symbol = new ol.style.Style({
- image: new ol.style.Icon({
- anchor: [0.5, 0.5],
- scale:0.4,
- src: "/src/views/zongHeXinXiOl/assets/p0.png"
- }),
- text: new ol.style.Text({
- font: 'normal 14px 黑体',
- // // 对其方式
- textAlign: 'center',
- // 基准线
- textBaseline: 'middle',
- offsetY: -15,
- offsetX: 0,
- fill: new ol.style.Fill({
- color: 'white'
- }),
- stroke: new ol.style.Stroke({
- color: 'black',
- lineCap: 'butt',
- width: 4
- }),
- padding: [5, 5, 5, 5],
- text: item.nm
- })
- });
- iconFeature.setStyle(symbol);
- features2.push(iconFeature)
- }else{
- item['layerId'] = 'szy_jsglGraphicLayer0';
- iconFeature.setProperties(item);
- symbol = new ol.style.Style({
- image: new ol.style.Icon({
- anchor: [0.5, 0.5],
- scale:0.4,
- src: "/src/views/zongHeXinXiOl/assets/p2.png"
- }),
- text: new ol.style.Text({
- font: 'normal 14px 黑体',
- // // 对其方式
- textAlign: 'center',
- // 基准线
- textBaseline: 'middle',
- offsetY: -15,
- offsetX: 0,
- fill: new ol.style.Fill({
- color: 'white'
- }),
- stroke: new ol.style.Stroke({
- color: 'black',
- lineCap: 'butt',
- width: 4
- }),
- padding: [5, 5, 5, 5],
- text: item.nm
- })
- });
- iconFeature.setStyle(symbol);
- features0.push(iconFeature)
- }
- }
- });
- var vectorSource0 = new ol.source.Vector({
- features: features0
- });
- var vectorLayer0 = new ol.layer.Vector({
- source: vectorSource0,
- id:'szy_jsglGraphicLayer0',
- visible:true
- });
- var vectorSource1 = new ol.source.Vector({
- features: features1
- });
- var vectorLayer1 = new ol.layer.Vector({
- source: vectorSource1,
- id:'szy_jsglGraphicLayer1',
- visible:true
- });
- var vectorSource2 = new ol.source.Vector({
- features: features2
- });
- var vectorLayer2 = new ol.layer.Vector({
- source: vectorSource2,
- id:'szy_jsglGraphicLayer2',
- visible:true
- });
- _self.mapObject.addLayer(vectorLayer0)
- _self.mapObject.addLayer(vectorLayer1)
- _self.mapObject.addLayer(vectorLayer2)
- }
- })
- }
|