gisviewer-vue3-arcgis
Version:
在应用中引入私服的包, 项目根目录下 新建文件 .npmrc 在 .npmrc 中对包源进行配置:
2 lines (1 loc) • 3.33 kB
JavaScript
;Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("ol/Feature"),y=require("ol/geom"),m=require("ol/layer/Vector"),E=require("ol/source/Vector"),r=require("ol/style"),M=require("vue"),S=require("../../stores/index.js"),A=require("./style/line-style.js");class D{constructor(t){this.initialized=!1,this.ddMap=new Map,this.zdMap=new Map,this.map=t,this.source=new E,this.policeAreaLayer=new m({source:this.source}),this.policeAreaLayer.set("id","police-area-layer"),this.map.addLayer(this.policeAreaLayer),this.zdBoundaryLayer=new m({source:new E}),this.zdBoundaryLayer.set("id","zd-boundary-layer"),this.map.addLayer(this.zdBoundaryLayer)}async initialize(){const t=S.default.useAppDataStore,i=M.toRaw(t.mapConfig),a=`${i.assetsRoot}/${i.policeArea.ddLayer}`;(await(await fetch(a)).json()).features.forEach(e=>{this.ddMap.set(e.properties.DD_CODE,{name:e.properties.DD_NAME,coordinates:e.geometry.coordinates,zdCode:e.properties.ZD_CODE})});const h=`${i.assetsRoot}/${i.policeArea.zdLayer}`;(await(await fetch(h)).json()).features.forEach(e=>{this.zdMap.set(e.properties.ZD_CODE,{name:e.properties.ZD_NAME,coordinates:e.geometry.coordinates})}),this.zdMap.forEach((e,d)=>{var l;const c=[];this.isMultiPolygon(e.coordinates)?e.coordinates.forEach(n=>{n.forEach(f=>c.push(f))}):e.coordinates.forEach(n=>{c.push(n)});const u=new y.Polygon(c),p=new g({geometry:u,type:"zd-boundary",id:d,name:e.name});p.setStyle(new r.Style({stroke:new r.Stroke({color:"rgba(30, 144, 255, 0.8)",width:1,lineDash:[10,20]})})),(l=this.zdBoundaryLayer.getSource())==null||l.addFeature(p)})}isMultiPolygon(t){return Array.isArray(t)&&Array.isArray(t[0])&&Array.isArray(t[0][0])&&Array.isArray(t[0][0][0])}async showJurisdiction(t){this.initialized||(await this.initialize(),this.initialized=!0),this.source.clear();const i=[[[-180,-90],[-180,90],[180,90],[180,-90],[-180,-90]]],a=[],w=s=>{this.isMultiPolygon(s)?s.forEach(o=>{o.forEach(e=>{a.push(e)})}):s.forEach(o=>{a.push(o)})};if(t.type==="zd"){const s=this.zdMap.get(t.id);s&&w(s.coordinates),this.ddMap.forEach((o,e)=>{if(o.zdCode===t.id){const d=[];this.isMultiPolygon(o.coordinates)?o.coordinates.forEach(n=>{n.forEach(f=>d.push(f))}):o.coordinates.forEach(n=>{d.push(n)});const c=new y.Polygon(d),u=new g({geometry:c,type:"dd-boundary",id:e,name:o.name});u.setStyle(A.getLineStyle({type:"simple-line",style:"dash",width:2,color:[30,144,255,.8]})),this.source.addFeature(u);const p=c.getInteriorPoint().getCoordinates(),l=new g({geometry:new y.Point(p),type:"dd-label",id:e,name:o.name});l.setStyle(new r.Style({text:new r.Text({text:o.name,font:"bold 14px sans-serif",fill:new r.Fill({color:"rgba(30, 144, 255, 1)"}),stroke:new r.Stroke({color:"#fff",width:3})})})),this.source.addFeature(l)}})}else if(t.type==="dd"){const s=this.ddMap.get(t.id);s&&w(s.coordinates)}console.log("holesToCut:",a),a.forEach(s=>{i.push(s)});const z=new y.Polygon(i),h=new g({geometry:z});if(console.log("maskCoords:",i),h.setStyle(new r.Style({fill:new r.Fill({color:"rgba(128, 128, 128, 0.6)"}),stroke:new r.Stroke({color:"rgba(30, 144, 255, 1)",width:2})})),this.source.addFeature(h),a.length>0){const o=new y.Polygon(a).getExtent();this.map.getView().fit(o,{padding:[50,50,50,50]})}}clearJurisdiction(){this.source.clear()}}exports.default=D;