UNPKG

gisviewer-vue3-arcgis

Version:

在应用中引入私服的包, 项目根目录下 新建文件 .npmrc 在 .npmrc 中对包源进行配置:

2 lines (1 loc) 2.16 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("@turf/helpers"),h=require("@turf/turf"),y=require("ol/Feature"),m=require("ol/geom"),S=require("ol/layer/Vector"),b=require("ol/source/Vector"),l=require("ol/style");function p(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const i in n)if(i!=="default"){const s=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:()=>n[i]})}}return t.default=n,Object.freeze(t)}const a=p(f);class w{constructor(t){this.map=t,this.source=new b,this.districtLayer=new S({source:this.source,style:this.createDistrictStyle()}),this.districtLayer.set("id","district-layer"),this.map.addLayer(this.districtLayer)}createDistrictStyle(){return[new l.Style({stroke:new l.Stroke({color:"rgba(111, 100, 255, 0.4)",width:2})}),new l.Style({stroke:new l.Stroke({color:"rgba(111, 100, 255, 1)",width:2,lineDash:[8,6]})})]}addDistricts(t){var s;this.source.clear();const i=[];for(const e of t){const r=e.getAllSignalCoordinates();let c=null;if(r.length>=2)if(r.length===2)c=a.lineString(r);else{const u=a.featureCollection(r.map(o=>a.point(o)));c=h.convex(u),c||(c=a.lineString(r))}else if(r.length===1)c=a.point(r[0]);else continue;const d=h.buffer(c.geometry,200,{units:"meters"});if(d){const u=d.geometry.coordinates,o=new y({geometry:new m.Polygon(u)});o.set("districtId",e.id),o.set("name",e.name),o.set("type","district"),this.source.addFeature(o);const g=(s=o.getGeometry())==null?void 0:s.getExtent();g&&i.push(g)}}if(i.length>0){const e=[...i[0]];return i.slice(1).forEach(r=>{e[0]=Math.min(e[0],r[0]),e[1]=Math.min(e[1],r[1]),e[2]=Math.max(e[2],r[2]),e[3]=Math.max(e[3],r[3])}),e}else return}setVisible(t){this.districtLayer.setVisible(t)}clear(){this.source.clear()}highlight(t){const i=t.id;let s=null;if(this.source.getFeatures().forEach(e=>{e.get("districtId")===i?(e.setStyle(void 0),s=e):e.setStyle(new l.Style({}))}),s){const e=s.getGeometry();if(e)return e.getExtent()}return null}clearHighlight(){this.source.getFeatures().forEach(t=>{t.setStyle(void 0)})}}exports.default=w;