gisviewer-vue3-arcgis 1.0.239 → 1.0.240

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,24 +1,25 @@
1
- import C from "@arcgis/core/Basemap";
2
- import d from "@arcgis/core/config";
3
- import * as k from "@arcgis/core/core/reactiveUtils";
4
- import { Multipoint as L, Polygon as W, Polyline as z, Point as T } from "@arcgis/core/geometry";
5
- import * as w from "@arcgis/core/geometry/support/webMercatorUtils";
1
+ import k from "@arcgis/core/Basemap";
2
+ import u from "@arcgis/core/config";
3
+ import * as T from "@arcgis/core/core/reactiveUtils";
4
+ import { Multipoint as P, Polygon as W, Polyline as z, Point as C } from "@arcgis/core/geometry";
5
+ import * as g from "@arcgis/core/geometry/support/webMercatorUtils";
6
6
  import x from "@arcgis/core/layers/FeatureLayer";
7
7
  import I from "@arcgis/core/layers/GeoJSONLayer";
8
- import R from "@arcgis/core/layers/IntegratedMesh3DTilesLayer";
8
+ import R from "@arcgis/core/layers/GroupLayer";
9
+ import G from "@arcgis/core/layers/IntegratedMesh3DTilesLayer";
9
10
  import H from "@arcgis/core/layers/MapImageLayer";
10
- import G from "@arcgis/core/layers/TileLayer";
11
+ import B from "@arcgis/core/layers/TileLayer";
11
12
  import O from "@arcgis/core/layers/WebTileLayer";
12
13
  import S from "@arcgis/core/Map";
13
- import B from "@arcgis/core/views/MapView";
14
- import N from "@arcgis/core/views/SceneView";
15
- import E from "@turf/destination";
16
- import * as A from "@turf/helpers";
17
- import J from "./custom-layer/custom-wmts-layer.mjs";
18
- function P(h, e) {
19
- return h && (h.startsWith("http://") || h.startsWith("https://") ? h : e + h);
14
+ import N from "@arcgis/core/views/MapView";
15
+ import E from "@arcgis/core/views/SceneView";
16
+ import A from "@turf/destination";
17
+ import * as J from "@turf/helpers";
18
+ import K from "./custom-layer/custom-wmts-layer.mjs";
19
+ function L(l, e) {
20
+ return l && (l.startsWith("http://") || l.startsWith("https://") ? l : e + l);
20
21
  }
21
- class te {
22
+ class oe {
22
23
  constructor() {
23
24
  this.mapConfig = {}, this.watchHandleMap = /* @__PURE__ */ new Map(), this.handleIndex = 0, this.zoomWatchHandle = null;
24
25
  }
@@ -28,19 +29,19 @@ class te {
28
29
  * @returns view
29
30
  */
30
31
  async initialize(e) {
31
- var p, u, b, y;
32
+ var f, b, v, y;
32
33
  this.mapConfig = e.mapConfig;
33
- const { container: i, markerClickCallback: o, mapClickCallback: r } = e;
34
- d.assetsPath = `${this.mapConfig.assetsRoot}/ArcgisAssets`, d.fontsUrl = `${this.mapConfig.assetsRoot}/fonts`, d.apiKey = "AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";
35
- const s = new S();
36
- if (((p = this.mapConfig) == null ? void 0 : p.mapOptions.mode.toLowerCase()) === "2d" ? (this.view = new B({
37
- map: s,
34
+ const { container: i, markerClickCallback: o, mapClickCallback: a } = e;
35
+ u.assetsPath = `${this.mapConfig.assetsRoot}/ArcgisAssets`, u.fontsUrl = `${this.mapConfig.assetsRoot}/fonts`, u.apiKey = "AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";
36
+ const r = new S();
37
+ if (((f = this.mapConfig) == null ? void 0 : f.mapOptions.mode.toLowerCase()) === "2d" ? (this.view = new N({
38
+ map: r,
38
39
  container: i,
39
40
  ...this.mapConfig.mapOptions
40
41
  }), this.view.on("drag", (t) => {
41
42
  t.button === 2 && t.stopPropagation();
42
- })) : this.view = new N({
43
- map: s,
43
+ })) : this.view = new E({
44
+ map: r,
44
45
  container: i,
45
46
  environment: {
46
47
  atmosphereEnabled: !0,
@@ -48,7 +49,7 @@ class te {
48
49
  type: "virtual"
49
50
  }
50
51
  },
51
- ...(u = this.mapConfig) == null ? void 0 : u.mapOptions
52
+ ...(b = this.mapConfig) == null ? void 0 : b.mapOptions
52
53
  }), this.view.popup.visibleElements = {
53
54
  closeButton: !0,
54
55
  collapseButton: !1,
@@ -58,109 +59,118 @@ class te {
58
59
  buttonEnabled: !1,
59
60
  breakpoint: !1
60
61
  }, this.view.on("click", async (t) => {
61
- var v, M;
62
- if (r) {
63
- let a = t.mapPoint;
64
- a.spatialReference.isWebMercator && (a = w.webMercatorToGeographic(
65
- a
66
- )), r(
67
- [a.x, a.y],
62
+ var h, M;
63
+ if (a) {
64
+ let s = t.mapPoint;
65
+ s.spatialReference.isWebMercator && (s = g.webMercatorToGeographic(
66
+ s
67
+ )), a(
68
+ [s.x, s.y],
68
69
  [t.screenPoint.x, t.screenPoint.y],
69
70
  t
70
71
  );
71
72
  }
72
73
  if (this.view.type === "3d") {
73
- const a = this.view.camera;
74
+ const s = this.view.camera;
74
75
  if (this.view.spatialReference.isWebMercator) {
75
- const m = w.webMercatorToGeographic(
76
- a.position
77
- ), f = {
78
- heading: a.heading,
79
- tilt: a.tilt,
76
+ const m = g.webMercatorToGeographic(
77
+ s.position
78
+ ), w = {
79
+ heading: s.heading,
80
+ tilt: s.tilt,
80
81
  position: m.toJSON()
81
82
  };
82
- console.log(f), (v = navigator.clipboard) == null || v.writeText(JSON.stringify(f));
83
+ console.log(w), (h = navigator.clipboard) == null || h.writeText(JSON.stringify(w));
83
84
  } else
84
- console.log(a.toJSON());
85
+ console.log(s.toJSON());
85
86
  console.log(this.view.zoom, this.view.scale);
86
87
  } else {
87
- let a = this.view.center;
88
- this.view.spatialReference.isWebMercator && (a = w.webMercatorToGeographic(
89
- a
88
+ let s = this.view.center;
89
+ this.view.spatialReference.isWebMercator && (s = g.webMercatorToGeographic(
90
+ s
90
91
  )), console.log({
91
- center: a.toJSON(),
92
+ center: s.toJSON(),
92
93
  zoom: this.view.zoom,
93
94
  scale: this.view.scale
94
95
  });
95
96
  }
96
97
  const n = (M = (await this.view.hitTest(t)).results) == null ? void 0 : M.filter(
97
- (a) => a.type === "graphic"
98
+ (s) => s.type === "graphic"
98
99
  );
99
- n.length > 0 && n.forEach((a) => {
100
- var f;
101
- const m = a.graphic;
102
- (f = m.attributes) != null && f.type && o && o(
100
+ n.length > 0 && n.forEach((s) => {
101
+ var w;
102
+ const m = s.graphic;
103
+ (w = m.attributes) != null && w.type && o && o(
103
104
  m.attributes.type,
104
105
  m.attributes.id,
105
106
  m.attributes,
106
107
  t
107
108
  );
108
109
  });
109
- }), (b = this.mapConfig) != null && b.baseLayers ? this.mapConfig.baseLayers.forEach((t) => {
110
- const c = P(t.url, this.mapConfig.assetsRoot);
110
+ }), (v = this.mapConfig) != null && v.baseLayers ? this.mapConfig.baseLayers.forEach((t) => {
111
+ const c = L(t.url, this.mapConfig.assetsRoot);
112
+ let n = null;
111
113
  switch (t.type.toLowerCase()) {
112
114
  case "webTile".toLowerCase(): {
113
- const n = new O({
115
+ n = new O({
114
116
  urlTemplate: c,
115
117
  ...t.options
116
118
  });
117
- s.add(n);
118
119
  break;
119
120
  }
120
121
  case "tile": {
121
- const n = new G({
122
+ n = new B({
122
123
  url: c,
123
124
  ...t.options
124
125
  });
125
- s.add(n);
126
126
  break;
127
127
  }
128
128
  case "customWMTS".toLowerCase(): {
129
- const n = new J({
129
+ n = new K({
130
130
  urlTemplate: c,
131
131
  ...t.options
132
132
  });
133
- s.add(n);
134
133
  break;
135
134
  }
136
135
  case "mapImage".toLowerCase(): {
137
- const n = new H({
136
+ n = new H({
138
137
  url: c,
139
138
  ...t.options
140
139
  });
141
- s.add(n);
142
140
  break;
143
141
  }
144
142
  case "arcgis": {
145
- const n = new C(t.options);
146
- s.basemap = n;
143
+ const h = new k(t.options);
144
+ r.basemap = h;
147
145
  break;
148
146
  }
149
147
  case "feature": {
150
- const n = new x({ url: c, ...t.options });
151
- s.add(n);
148
+ n = new x({ url: c, ...t.options });
152
149
  break;
153
150
  }
154
151
  case "3dtiles": {
155
- const n = new R({
152
+ n = new G({
156
153
  url: c,
157
154
  ...t.options
158
155
  });
159
- s.add(n);
160
156
  break;
161
157
  }
158
+ default:
159
+ console.warn(`不支持的图层类型: ${t.type}`);
160
+ break;
162
161
  }
163
- }) : s.basemap = new C({
162
+ if (n)
163
+ if (t.group) {
164
+ let h = r.findLayerById(t.group);
165
+ console.log(h), h && h.type === "group" ? h.add(n) : (h = new R({
166
+ id: t.group,
167
+ title: t.groupTitle,
168
+ visibilityMode: "inherited",
169
+ layers: [n]
170
+ }), r.add(h));
171
+ } else
172
+ r.add(n);
173
+ }) : r.basemap = new k({
164
174
  style: {
165
175
  id: "arcgis/light-gray",
166
176
  language: "zh-CN"
@@ -170,37 +180,37 @@ class te {
170
180
  (c) => (
171
181
  // 图层文件为GeoJson格式, renderer和symbol使用autocast配置
172
182
  new I({
173
- url: P(c.url, this.mapConfig.assetsRoot),
183
+ url: L(c.url, this.mapConfig.assetsRoot),
174
184
  ...c.options,
175
185
  title: c.options.id
176
186
  })
177
187
  )
178
188
  );
179
- s.addMany(t);
189
+ r.addMany(t);
180
190
  }
181
191
  this.view.ui.remove("attribution"), await this.view.when();
182
- const g = this.mapConfig.camera;
183
- let l;
192
+ const d = this.mapConfig.camera;
193
+ let p;
184
194
  if (this.view.type === "2d") {
185
195
  let t = this.view.center;
186
- this.view.spatialReference.isWebMercator && (t = w.webMercatorToGeographic(
196
+ this.view.spatialReference.isWebMercator && (t = g.webMercatorToGeographic(
187
197
  t
188
- )), l = { center: [t.x, t.y], zoom: this.view.zoom };
198
+ )), p = { center: [t.x, t.y], zoom: this.view.zoom };
189
199
  } else {
190
200
  let t = this.view.camera.position;
191
- this.view.spatialReference.isWebMercator && (t = w.webMercatorToGeographic(
201
+ this.view.spatialReference.isWebMercator && (t = g.webMercatorToGeographic(
192
202
  t
193
- )), l = {
203
+ )), p = {
194
204
  position: t,
195
205
  heading: this.view.camera.heading,
196
206
  tilt: this.view.camera.tilt
197
207
  };
198
208
  }
199
- return g ? g.home = l : this.mapConfig.camera = { home: l }, this.view;
209
+ return d ? d.home = p : this.mapConfig.camera = { home: p }, this.view;
200
210
  }
201
211
  setLayerVisibility(e) {
202
- const { id: i, visible: o } = e, r = this.view.map.findLayerById(i);
203
- return r ? (r.visible = o, { status: 0, message: "ok" }) : { status: -1, message: "未找到图层" };
212
+ const { id: i, visible: o } = e, a = this.view.map.findLayerById(i);
213
+ return a ? (a.visible = o, { status: 0, message: "ok" }) : { status: -1, message: "未找到图层" };
204
214
  }
205
215
  /**
206
216
  * 设置地图中心点
@@ -214,7 +224,7 @@ class te {
214
224
  if (e.center || e.target) {
215
225
  switch ((i = e.target) == null ? void 0 : i.type.toLowerCase()) {
216
226
  case "point":
217
- e.target = new T(e.target);
227
+ e.target = new C(e.target);
218
228
  break;
219
229
  case "polyline":
220
230
  e.target = new z(e.target);
@@ -223,7 +233,7 @@ class te {
223
233
  e.target = new W(e.target);
224
234
  break;
225
235
  case "multipoint":
226
- e.target = new L(e.target);
236
+ e.target = new P(e.target);
227
237
  break;
228
238
  }
229
239
  await this.view.goTo(e, { duration: (e.duration || 0) * 1e3 });
@@ -251,9 +261,9 @@ class te {
251
261
  { duration: (e.duration || 2) * 1e3 }
252
262
  );
253
263
  else {
254
- const r = Math.tan(i * Math.PI / 180) * e.height, s = E(
255
- A.point(e.center),
256
- r,
264
+ const a = Math.tan(i * Math.PI / 180) * e.height, r = A(
265
+ J.point(e.center),
266
+ a,
257
267
  o + 180,
258
268
  {
259
269
  units: "meters"
@@ -262,8 +272,8 @@ class te {
262
272
  await this.view.goTo(
263
273
  {
264
274
  position: {
265
- x: s.geometry.coordinates[0],
266
- y: s.geometry.coordinates[1],
275
+ x: r.geometry.coordinates[0],
276
+ y: r.geometry.coordinates[1],
267
277
  z: e.height
268
278
  },
269
279
  heading: o,
@@ -276,33 +286,33 @@ class te {
276
286
  async setMapCamera(e) {
277
287
  if (!this.view)
278
288
  return { status: -1, message: "未初始化" };
279
- const { name: i, duration: o = 0 } = e, { camera: r } = this.mapConfig;
280
- if (!r)
289
+ const { name: i, duration: o = 0 } = e, { camera: a } = this.mapConfig;
290
+ if (!a)
281
291
  return { status: -1, message: "未配置camera" };
282
- const s = r[i];
283
- return s ? (await this.view.goTo(s, { duration: o * 1e3 }), { status: 0, message: "成功" }) : { status: -1, message: "未配置camera" };
292
+ const r = a[i];
293
+ return r ? (await this.view.goTo(r, { duration: o * 1e3 }), { status: 0, message: "成功" }) : { status: -1, message: "未配置camera" };
284
294
  }
285
295
  /**
286
296
  * 经纬度转像素坐标,在地图移动时回调
287
297
  * */
288
298
  requestCoordinateTransform(e, i) {
289
299
  let o = 0;
290
- const s = 1e3 / 30, g = k.watch(
300
+ const r = 1e3 / 30, d = T.watch(
291
301
  () => this.view.center,
292
302
  () => {
293
- const l = this.transformPoints(e), p = Date.now();
294
- p - o > s && (i(l), o = p);
303
+ const p = this.transformPoints(e), f = Date.now();
304
+ f - o > r && (i(p), o = f);
295
305
  }
296
306
  );
297
- return this.handleIndex++, this.watchHandleMap.set(this.handleIndex, g), { handle: this.handleIndex, points: this.transformPoints(e) };
307
+ return this.handleIndex++, this.watchHandleMap.set(this.handleIndex, d), { handle: this.handleIndex, points: this.transformPoints(e) };
298
308
  }
299
309
  transformPoints(e) {
300
310
  return e.map((i) => {
301
- const o = new T({
311
+ const o = new C({
302
312
  x: i[0],
303
313
  y: i[1]
304
- }), r = this.view.toScreen(o);
305
- return [r.x, r.y];
314
+ }), a = this.view.toScreen(o);
315
+ return [a.x, a.y];
306
316
  });
307
317
  }
308
318
  /**
@@ -317,14 +327,14 @@ class te {
317
327
  * */
318
328
  setMapZoomRange(e) {
319
329
  const { min: i, max: o } = e;
320
- !i && !o || (this.zoomWatchHandle && this.zoomWatchHandle.remove(), this.zoomWatchHandle = k.watch(
330
+ !i && !o || (this.zoomWatchHandle && this.zoomWatchHandle.remove(), this.zoomWatchHandle = T.watch(
321
331
  () => this.view.zoom,
322
- (r) => {
323
- i && r <= i && (this.view.zoom = i), o && r >= o && (this.view.zoom = o);
332
+ (a) => {
333
+ i && a <= i && (this.view.zoom = i), o && a >= o && (this.view.zoom = o);
324
334
  }
325
335
  ));
326
336
  }
327
337
  }
328
338
  export {
329
- te as default
339
+ oe as default
330
340
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("@arcgis/core/Basemap"),g=require("@arcgis/core/config"),q=require("@arcgis/core/core/reactiveUtils"),f=require("@arcgis/core/geometry"),z=require("@arcgis/core/geometry/support/webMercatorUtils"),W=require("@arcgis/core/layers/FeatureLayer"),O=require("@arcgis/core/layers/GeoJSONLayer"),x=require("@arcgis/core/layers/IntegratedMesh3DTilesLayer"),I=require("@arcgis/core/layers/MapImageLayer"),S=require("@arcgis/core/layers/TileLayer"),R=require("@arcgis/core/layers/WebTileLayer"),H=require("@arcgis/core/Map"),_=require("@arcgis/core/views/MapView"),G=require("@arcgis/core/views/SceneView"),j=require("@turf/destination"),B=require("@turf/helpers"),N=require("./custom-layer/custom-wmts-layer.js");function b(c){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const t in c)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(c,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>c[t]})}}return e.default=c,Object.freeze(e)}const T=b(q),m=b(z),U=b(B);function L(c,e){return c&&(c.startsWith("http://")||c.startsWith("https://")?c:e+c)}class E{constructor(){this.mapConfig={},this.watchHandleMap=new Map,this.handleIndex=0,this.zoomWatchHandle=null}async initialize(e){var u,y,v,M;this.mapConfig=e.mapConfig;const{container:t,markerClickCallback:s,mapClickCallback:n}=e;g.assetsPath=`${this.mapConfig.assetsRoot}/ArcgisAssets`,g.fontsUrl=`${this.mapConfig.assetsRoot}/fonts`,g.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const a=new H;if(((u=this.mapConfig)==null?void 0:u.mapOptions.mode.toLowerCase())==="2d"?(this.view=new _({map:a,container:t,...this.mapConfig.mapOptions}),this.view.on("drag",i=>{i.button===2&&i.stopPropagation()})):this.view=new G({map:a,container:t,environment:{atmosphereEnabled:!0,lighting:{type:"virtual"}},...(y=this.mapConfig)==null?void 0:y.mapOptions}),this.view.popup.visibleElements={closeButton:!0,collapseButton:!1,actionBar:!1,featureNavigation:!0},this.view.popup.dockOptions={buttonEnabled:!1,breakpoint:!1},this.view.on("click",async i=>{var k,C;if(n){let o=i.mapPoint;o.spatialReference.isWebMercator&&(o=m.webMercatorToGeographic(o)),n([o.x,o.y],[i.screenPoint.x,i.screenPoint.y],i)}if(this.view.type==="3d"){const o=this.view.camera;if(this.view.spatialReference.isWebMercator){const p=m.webMercatorToGeographic(o.position),w={heading:o.heading,tilt:o.tilt,position:p.toJSON()};console.log(w),(k=navigator.clipboard)==null||k.writeText(JSON.stringify(w))}else console.log(o.toJSON());console.log(this.view.zoom,this.view.scale)}else{let o=this.view.center;this.view.spatialReference.isWebMercator&&(o=m.webMercatorToGeographic(o)),console.log({center:o.toJSON(),zoom:this.view.zoom,scale:this.view.scale})}const r=(C=(await this.view.hitTest(i)).results)==null?void 0:C.filter(o=>o.type==="graphic");r.length>0&&r.forEach(o=>{var w;const p=o.graphic;(w=p.attributes)!=null&&w.type&&s&&s(p.attributes.type,p.attributes.id,p.attributes,i)})}),(v=this.mapConfig)!=null&&v.baseLayers?this.mapConfig.baseLayers.forEach(i=>{const l=L(i.url,this.mapConfig.assetsRoot);switch(i.type.toLowerCase()){case"webTile".toLowerCase():{const r=new R({urlTemplate:l,...i.options});a.add(r);break}case"tile":{const r=new S({url:l,...i.options});a.add(r);break}case"customWMTS".toLowerCase():{const r=new N.default({urlTemplate:l,...i.options});a.add(r);break}case"mapImage".toLowerCase():{const r=new I({url:l,...i.options});a.add(r);break}case"arcgis":{const r=new P(i.options);a.basemap=r;break}case"feature":{const r=new W({url:l,...i.options});a.add(r);break}case"3dtiles":{const r=new x({url:l,...i.options});a.add(r);break}}}):a.basemap=new P({style:{id:"arcgis/light-gray",language:"zh-CN"}}),(M=this.mapConfig)!=null&&M.hdLayers){const i=this.mapConfig.hdLayers.map(l=>new O({url:L(l.url,this.mapConfig.assetsRoot),...l.options,title:l.options.id}));a.addMany(i)}this.view.ui.remove("attribution"),await this.view.when();const d=this.mapConfig.camera;let h;if(this.view.type==="2d"){let i=this.view.center;this.view.spatialReference.isWebMercator&&(i=m.webMercatorToGeographic(i)),h={center:[i.x,i.y],zoom:this.view.zoom}}else{let i=this.view.camera.position;this.view.spatialReference.isWebMercator&&(i=m.webMercatorToGeographic(i)),h={position:i,heading:this.view.camera.heading,tilt:this.view.camera.tilt}}return d?d.home=h:this.mapConfig.camera={home:h},this.view}setLayerVisibility(e){const{id:t,visible:s}=e,n=this.view.map.findLayerById(t);return n?(n.visible=s,{status:0,message:"ok"}):{status:-1,message:"未找到图层"}}async setMapCenter(e){var t;if(!this.view)return{status:-1,message:"未初始化"};if(e.center||e.target){switch((t=e.target)==null?void 0:t.type.toLowerCase()){case"point":e.target=new f.Point(e.target);break;case"polyline":e.target=new f.Polyline(e.target);break;case"polygon":e.target=new f.Polygon(e.target);break;case"multipoint":e.target=new f.Multipoint(e.target);break}await this.view.goTo(e,{duration:(e.duration||0)*1e3})}return{status:0,message:"成功"}}async lookAt(e){if(this.view.type==="2d")return;const t=e.tilt||0,s=e.heading||0;if(t===0)await this.view.goTo({position:{x:e.center[0],y:e.center[1],z:e.height},heading:s,tilt:0},{duration:(e.duration||2)*1e3});else{const n=Math.tan(t*Math.PI/180)*e.height,a=j(U.point(e.center),n,s+180,{units:"meters"});await this.view.goTo({position:{x:a.geometry.coordinates[0],y:a.geometry.coordinates[1],z:e.height},heading:s,tilt:t},{duration:(e.duration||2)*1e3})}}async setMapCamera(e){if(!this.view)return{status:-1,message:"未初始化"};const{name:t,duration:s=0}=e,{camera:n}=this.mapConfig;if(!n)return{status:-1,message:"未配置camera"};const a=n[t];return a?(await this.view.goTo(a,{duration:s*1e3}),{status:0,message:"成功"}):{status:-1,message:"未配置camera"}}requestCoordinateTransform(e,t){let s=0;const a=1e3/30,d=T.watch(()=>this.view.center,()=>{const h=this.transformPoints(e),u=Date.now();u-s>a&&(t(h),s=u)});return this.handleIndex++,this.watchHandleMap.set(this.handleIndex,d),{handle:this.handleIndex,points:this.transformPoints(e)}}transformPoints(e){return e.map(t=>{const s=new f.Point({x:t[0],y:t[1]}),n=this.view.toScreen(s);return[n.x,n.y]})}cancelCoordinateTransform(e){const t=this.watchHandleMap.get(e);t&&(t.remove(),this.watchHandleMap.delete(e))}setMapZoomRange(e){const{min:t,max:s}=e;!t&&!s||(this.zoomWatchHandle&&this.zoomWatchHandle.remove(),this.zoomWatchHandle=T.watch(()=>this.view.zoom,n=>{t&&n<=t&&(this.view.zoom=t),s&&n>=s&&(this.view.zoom=s)}))}}exports.default=E;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const T=require("@arcgis/core/Basemap"),b=require("@arcgis/core/config"),q=require("@arcgis/core/core/reactiveUtils"),m=require("@arcgis/core/geometry"),z=require("@arcgis/core/geometry/support/webMercatorUtils"),W=require("@arcgis/core/layers/FeatureLayer"),O=require("@arcgis/core/layers/GeoJSONLayer"),I=require("@arcgis/core/layers/GroupLayer"),x=require("@arcgis/core/layers/IntegratedMesh3DTilesLayer"),S=require("@arcgis/core/layers/MapImageLayer"),R=require("@arcgis/core/layers/TileLayer"),G=require("@arcgis/core/layers/WebTileLayer"),H=require("@arcgis/core/Map"),_=require("@arcgis/core/views/MapView"),B=require("@arcgis/core/views/SceneView"),j=require("@turf/destination"),N=require("@turf/helpers"),U=require("./custom-layer/custom-wmts-layer.js");function v(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const i in r)if(i!=="default"){const s=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}return e.default=r,Object.freeze(e)}const L=v(q),g=v(z),E=v(N);function C(r,e){return r&&(r.startsWith("http://")||r.startsWith("https://")?r:e+r)}class A{constructor(){this.mapConfig={},this.watchHandleMap=new Map,this.handleIndex=0,this.zoomWatchHandle=null}async initialize(e){var w,y,M,k;this.mapConfig=e.mapConfig;const{container:i,markerClickCallback:s,mapClickCallback:a}=e;b.assetsPath=`${this.mapConfig.assetsRoot}/ArcgisAssets`,b.fontsUrl=`${this.mapConfig.assetsRoot}/fonts`,b.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const n=new H;if(((w=this.mapConfig)==null?void 0:w.mapOptions.mode.toLowerCase())==="2d"?(this.view=new _({map:n,container:i,...this.mapConfig.mapOptions}),this.view.on("drag",t=>{t.button===2&&t.stopPropagation()})):this.view=new B({map:n,container:i,environment:{atmosphereEnabled:!0,lighting:{type:"virtual"}},...(y=this.mapConfig)==null?void 0:y.mapOptions}),this.view.popup.visibleElements={closeButton:!0,collapseButton:!1,actionBar:!1,featureNavigation:!0},this.view.popup.dockOptions={buttonEnabled:!1,breakpoint:!1},this.view.on("click",async t=>{var h,P;if(a){let o=t.mapPoint;o.spatialReference.isWebMercator&&(o=g.webMercatorToGeographic(o)),a([o.x,o.y],[t.screenPoint.x,t.screenPoint.y],t)}if(this.view.type==="3d"){const o=this.view.camera;if(this.view.spatialReference.isWebMercator){const p=g.webMercatorToGeographic(o.position),f={heading:o.heading,tilt:o.tilt,position:p.toJSON()};console.log(f),(h=navigator.clipboard)==null||h.writeText(JSON.stringify(f))}else console.log(o.toJSON());console.log(this.view.zoom,this.view.scale)}else{let o=this.view.center;this.view.spatialReference.isWebMercator&&(o=g.webMercatorToGeographic(o)),console.log({center:o.toJSON(),zoom:this.view.zoom,scale:this.view.scale})}const c=(P=(await this.view.hitTest(t)).results)==null?void 0:P.filter(o=>o.type==="graphic");c.length>0&&c.forEach(o=>{var f;const p=o.graphic;(f=p.attributes)!=null&&f.type&&s&&s(p.attributes.type,p.attributes.id,p.attributes,t)})}),(M=this.mapConfig)!=null&&M.baseLayers?this.mapConfig.baseLayers.forEach(t=>{const l=C(t.url,this.mapConfig.assetsRoot);let c=null;switch(t.type.toLowerCase()){case"webTile".toLowerCase():{c=new G({urlTemplate:l,...t.options});break}case"tile":{c=new R({url:l,...t.options});break}case"customWMTS".toLowerCase():{c=new U.default({urlTemplate:l,...t.options});break}case"mapImage".toLowerCase():{c=new S({url:l,...t.options});break}case"arcgis":{const h=new T(t.options);n.basemap=h;break}case"feature":{c=new W({url:l,...t.options});break}case"3dtiles":{c=new x({url:l,...t.options});break}default:console.warn(`不支持的图层类型: ${t.type}`);break}if(c)if(t.group){let h=n.findLayerById(t.group);console.log(h),h&&h.type==="group"?h.add(c):(h=new I({id:t.group,title:t.groupTitle,visibilityMode:"inherited",layers:[c]}),n.add(h))}else n.add(c)}):n.basemap=new T({style:{id:"arcgis/light-gray",language:"zh-CN"}}),(k=this.mapConfig)!=null&&k.hdLayers){const t=this.mapConfig.hdLayers.map(l=>new O({url:C(l.url,this.mapConfig.assetsRoot),...l.options,title:l.options.id}));n.addMany(t)}this.view.ui.remove("attribution"),await this.view.when();const d=this.mapConfig.camera;let u;if(this.view.type==="2d"){let t=this.view.center;this.view.spatialReference.isWebMercator&&(t=g.webMercatorToGeographic(t)),u={center:[t.x,t.y],zoom:this.view.zoom}}else{let t=this.view.camera.position;this.view.spatialReference.isWebMercator&&(t=g.webMercatorToGeographic(t)),u={position:t,heading:this.view.camera.heading,tilt:this.view.camera.tilt}}return d?d.home=u:this.mapConfig.camera={home:u},this.view}setLayerVisibility(e){const{id:i,visible:s}=e,a=this.view.map.findLayerById(i);return a?(a.visible=s,{status:0,message:"ok"}):{status:-1,message:"未找到图层"}}async setMapCenter(e){var i;if(!this.view)return{status:-1,message:"未初始化"};if(e.center||e.target){switch((i=e.target)==null?void 0:i.type.toLowerCase()){case"point":e.target=new m.Point(e.target);break;case"polyline":e.target=new m.Polyline(e.target);break;case"polygon":e.target=new m.Polygon(e.target);break;case"multipoint":e.target=new m.Multipoint(e.target);break}await this.view.goTo(e,{duration:(e.duration||0)*1e3})}return{status:0,message:"成功"}}async lookAt(e){if(this.view.type==="2d")return;const i=e.tilt||0,s=e.heading||0;if(i===0)await this.view.goTo({position:{x:e.center[0],y:e.center[1],z:e.height},heading:s,tilt:0},{duration:(e.duration||2)*1e3});else{const a=Math.tan(i*Math.PI/180)*e.height,n=j(E.point(e.center),a,s+180,{units:"meters"});await this.view.goTo({position:{x:n.geometry.coordinates[0],y:n.geometry.coordinates[1],z:e.height},heading:s,tilt:i},{duration:(e.duration||2)*1e3})}}async setMapCamera(e){if(!this.view)return{status:-1,message:"未初始化"};const{name:i,duration:s=0}=e,{camera:a}=this.mapConfig;if(!a)return{status:-1,message:"未配置camera"};const n=a[i];return n?(await this.view.goTo(n,{duration:s*1e3}),{status:0,message:"成功"}):{status:-1,message:"未配置camera"}}requestCoordinateTransform(e,i){let s=0;const n=1e3/30,d=L.watch(()=>this.view.center,()=>{const u=this.transformPoints(e),w=Date.now();w-s>n&&(i(u),s=w)});return this.handleIndex++,this.watchHandleMap.set(this.handleIndex,d),{handle:this.handleIndex,points:this.transformPoints(e)}}transformPoints(e){return e.map(i=>{const s=new m.Point({x:i[0],y:i[1]}),a=this.view.toScreen(s);return[a.x,a.y]})}cancelCoordinateTransform(e){const i=this.watchHandleMap.get(e);i&&(i.remove(),this.watchHandleMap.delete(e))}setMapZoomRange(e){const{min:i,max:s}=e;!i&&!s||(this.zoomWatchHandle&&this.zoomWatchHandle.remove(),this.zoomWatchHandle=L.watch(()=>this.view.zoom,a=>{i&&a<=i&&(this.view.zoom=i),s&&a>=s&&(this.view.zoom=s)}))}}exports.default=A;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.239",
3
+ "version": "1.0.240",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [