UNPKG

gisviewer-vue3-arcgis

Version:

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

2 lines (1 loc) 1.27 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("@arcgis/core/geometry/Extent.js");class h{constructor(t){this.viewer=t.viewer,this.points=t.points}flyToPoints(){if(this.points.length==0)return;const t=this.calculateExtent(this.points),n=t.center,i=Math.abs(t.xmax-t.xmin),o=Math.abs(t.ymax-t.ymin),a=.6,e=i*a,l=o*a,s=new c({xmin:t.xmin-e,ymin:t.ymin-l,xmax:t.xmax+e,ymax:t.ymax+l,spatialReference:t.spatialReference}),r=this.calculateZoomLevel(s,this.viewer.width,this.viewer.height);this.viewer.goTo({target:s,zoom:r,center:n})}calculateZoomLevel(t,n,i){const o=Math.abs(t.xmax-t.xmin),a=Math.abs(t.ymax-t.ymin),e=Math.log2(360*(n/o)/256),l=Math.log2(180*(i/a)/256);return Math.floor(Math.min(e,l))}calculateExtent(t){let n=Number.MAX_VALUE,i=Number.MAX_VALUE,o=Number.MIN_VALUE,a=Number.MIN_VALUE;for(let e=0;e<t.length;e++){const l=t[e];n=Math.min(n,l.longitude),i=Math.min(i,l.latitude),o=Math.max(o,l.longitude),a=Math.max(a,l.latitude)}return new c({xmin:n,ymin:i,xmax:o,ymax:a,spatialReference:{wkid:4326}})}calculateCenterPoint(t){let n=0,i=0;for(let e=0;e<t.length;e++)n+=t[e].longitude,i+=t[e].latitude;const o=n/t.length,a=i/t.length;return{longitude:o,latitude:a}}}exports.default=h;