UNPKG

gisviewer-vue3-arcgis

Version:

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

2 lines (1 loc) 3.41 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("ol/Feature"),i=require("ol/geom/Point"),h=require("ol/layer/Vector"),l=require("ol/Observable"),y=require("ol/source/Vector"),n=require("ol/style/Fill"),g=require("ol/style/Icon"),C=require("ol/style/Stroke"),u=require("ol/style/Style"),m=require("ol/style/Text"),d=require("../cluster/pixel-cluster-calculator.js"),c=require("../style/point-style.js");class S{constructor(t){this.countBackgroundColor=[2,72,200,.8],this.countFontColor=[255,255,255,1],this.locations=[],this.clusterMarkUrl="",this.viewChangeKey=null,this.mapMoveKey=null,this.resolutionChangeTimeout=null,this.map=t,this.view=t.getView(),this.clusterCalculator=new d.PixelClusterCalculator(t),this.source=new y,this.clusterLayer=new h({source:this.source}),this.clusterLayer.set("id","cluster-points-layer"),this.map.addLayer(this.clusterLayer),this.configureVectorLayerStyle()}addClusterPoints(t){var e;this.clusterMarkUrl=((e=t.clusterSymbol)==null?void 0:e.url)||"/GisViewerAssets/Images/cross/gis_xhj_blue.png",this.countBackgroundColor=t.countBackgroundColor||this.countBackgroundColor,this.countFontColor=t.countFontColor||this.countFontColor,this.locations=t.points,this.locations.forEach(o=>{o.symbol=o.symbol||t.pointSymbol}),this.viewChangeKey||(this.viewChangeKey=this.view.on("change:resolution",()=>{this.resolutionChangeTimeout&&clearTimeout(this.resolutionChangeTimeout),this.resolutionChangeTimeout=setTimeout(()=>{this.calculateCluster()},150)})),this.mapMoveKey||(this.mapMoveKey=this.map.on("moveend",()=>{this.calculateCluster()})),this.calculateCluster()}removeAllClusterPoints(){this.source.clear(),this.viewChangeKey&&(l.unByKey(this.viewChangeKey),this.viewChangeKey=null),this.mapMoveKey&&(l.unByKey(this.mapMoveKey),this.mapMoveKey=null),this.resolutionChangeTimeout&&(clearTimeout(this.resolutionChangeTimeout),this.resolutionChangeTimeout=null)}configureVectorLayerStyle(){const t=this.view.getResolutionForZoom(18);this.clusterLayer.setStyle((e,o)=>{const s=e.get("type");if(o<=t)return c.getPointStyle(e.getProperties().symbol);if(s==="cluster-point")return c.getPointStyle(e.getProperties().symbol);if(s==="cluster-cluster")return this.getClusterStyle(e.getProperties())})}getClusterStyle(t){const e=t.clusterSymbolSize,o=new g({src:this.clusterMarkUrl,scale:e/32}),s=-(e+10),a=new m({text:String(t.count??0),font:"16px Arial Unicode MS",fill:new n({color:this.countFontColor}),backgroundFill:new n({color:this.countBackgroundColor}),backgroundStroke:new C({color:[this.countBackgroundColor[0],this.countBackgroundColor[1],this.countBackgroundColor[2],.5],width:4}),padding:[1,2,1,2],offsetY:s,textAlign:"center",justify:"center",textBaseline:"middle"});return[new u({image:o}),new u({text:a})]}showClusterResult(t){this.source.clear(),t.forEach(e=>{if(e.id!==-1&&e.center&&e.symbolSize){const o=new r({geometry:new i([e.center.x,e.center.y]),type:"cluster-cluster",count:e.count,clusterSymbolSize:e.symbolSize});this.source.addFeature(o)}else e.items.forEach(o=>{const s=new r({...o.properties,geometry:new i([o.x,o.y]),type:"cluster-point",symbol:o.symbol});this.source.addFeature(s)})}),this.clusterLayer.changed()}calculateCluster(){const t=this.clusterCalculator.calculate(this.locations),e=this.clusterCalculator.calculateSymbolSizes(t);this.showClusterResult(e)}}exports.default=S;