UNPKG

gisviewer-vue3-arcgis

Version:

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

68 lines (67 loc) 1.81 kB
import c from "@arcgis/core/geometry/Extent.js"; class u { // private duration: number; constructor(t) { this.viewer = t.viewer, this.points = t.points; } /** * 移动到可视角度 * * @returns * @memberof FlyToPoints */ 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 = 0.6, e = i * a, l = o * a, h = new c({ xmin: t.xmin - e, ymin: t.ymin - l, xmax: t.xmax + e, ymax: t.ymax + l, spatialReference: t.spatialReference }), m = this.calculateZoomLevel( h, this.viewer.width, this.viewer.height ); this.viewer.goTo({ target: h, zoom: m, 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 // Assuming WGS84 spatial reference system } }); } 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 }; } } export { u as default };