gisviewer-vue3-arcgis 1.0.237 → 1.0.238
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,24 @@
|
|
|
1
1
|
import C from "@arcgis/core/Basemap";
|
|
2
|
-
import
|
|
2
|
+
import d from "@arcgis/core/config";
|
|
3
3
|
import * as k from "@arcgis/core/core/reactiveUtils";
|
|
4
|
-
import {
|
|
4
|
+
import { Multipoint as L, Polygon as W, Polyline as z, Point as T } from "@arcgis/core/geometry";
|
|
5
5
|
import * as w from "@arcgis/core/geometry/support/webMercatorUtils";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import * as
|
|
17
|
-
import
|
|
6
|
+
import x from "@arcgis/core/layers/FeatureLayer";
|
|
7
|
+
import I from "@arcgis/core/layers/GeoJSONLayer";
|
|
8
|
+
import R from "@arcgis/core/layers/IntegratedMesh3DTilesLayer";
|
|
9
|
+
import H from "@arcgis/core/layers/MapImageLayer";
|
|
10
|
+
import G from "@arcgis/core/layers/TileLayer";
|
|
11
|
+
import O from "@arcgis/core/layers/WebTileLayer";
|
|
12
|
+
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
18
|
function P(h, e) {
|
|
19
19
|
return h && (h.startsWith("http://") || h.startsWith("https://") ? h : e + h);
|
|
20
20
|
}
|
|
21
|
-
class
|
|
21
|
+
class te {
|
|
22
22
|
constructor() {
|
|
23
23
|
this.mapConfig = {}, this.watchHandleMap = /* @__PURE__ */ new Map(), this.handleIndex = 0, this.zoomWatchHandle = null;
|
|
24
24
|
}
|
|
@@ -31,15 +31,15 @@ class ee {
|
|
|
31
31
|
var p, u, b, y;
|
|
32
32
|
this.mapConfig = e.mapConfig;
|
|
33
33
|
const { container: i, markerClickCallback: o, mapClickCallback: r } = e;
|
|
34
|
-
|
|
35
|
-
const s = new
|
|
36
|
-
if (((p = this.mapConfig) == null ? void 0 : p.mapOptions.mode.toLowerCase()) === "2d" ? (this.view = new
|
|
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
37
|
map: s,
|
|
38
38
|
container: i,
|
|
39
39
|
...this.mapConfig.mapOptions
|
|
40
40
|
}), this.view.on("drag", (t) => {
|
|
41
41
|
t.button === 2 && t.stopPropagation();
|
|
42
|
-
})) : this.view = new
|
|
42
|
+
})) : this.view = new N({
|
|
43
43
|
map: s,
|
|
44
44
|
container: i,
|
|
45
45
|
environment: {
|
|
@@ -110,7 +110,7 @@ class ee {
|
|
|
110
110
|
const c = P(t.url, this.mapConfig.assetsRoot);
|
|
111
111
|
switch (t.type.toLowerCase()) {
|
|
112
112
|
case "webTile".toLowerCase(): {
|
|
113
|
-
const n = new
|
|
113
|
+
const n = new O({
|
|
114
114
|
urlTemplate: c,
|
|
115
115
|
...t.options
|
|
116
116
|
});
|
|
@@ -118,7 +118,7 @@ class ee {
|
|
|
118
118
|
break;
|
|
119
119
|
}
|
|
120
120
|
case "tile": {
|
|
121
|
-
const n = new
|
|
121
|
+
const n = new G({
|
|
122
122
|
url: c,
|
|
123
123
|
...t.options
|
|
124
124
|
});
|
|
@@ -126,7 +126,7 @@ class ee {
|
|
|
126
126
|
break;
|
|
127
127
|
}
|
|
128
128
|
case "customWMTS".toLowerCase(): {
|
|
129
|
-
const n = new
|
|
129
|
+
const n = new J({
|
|
130
130
|
urlTemplate: c,
|
|
131
131
|
...t.options
|
|
132
132
|
});
|
|
@@ -134,7 +134,7 @@ class ee {
|
|
|
134
134
|
break;
|
|
135
135
|
}
|
|
136
136
|
case "mapImage".toLowerCase(): {
|
|
137
|
-
const n = new
|
|
137
|
+
const n = new H({
|
|
138
138
|
url: c,
|
|
139
139
|
...t.options
|
|
140
140
|
});
|
|
@@ -147,12 +147,12 @@ class ee {
|
|
|
147
147
|
break;
|
|
148
148
|
}
|
|
149
149
|
case "feature": {
|
|
150
|
-
const n = new
|
|
150
|
+
const n = new x({ url: c, ...t.options });
|
|
151
151
|
s.add(n);
|
|
152
152
|
break;
|
|
153
153
|
}
|
|
154
154
|
case "3dtiles": {
|
|
155
|
-
const n = new
|
|
155
|
+
const n = new R({
|
|
156
156
|
url: c,
|
|
157
157
|
...t.options
|
|
158
158
|
});
|
|
@@ -169,7 +169,7 @@ class ee {
|
|
|
169
169
|
const t = this.mapConfig.hdLayers.map(
|
|
170
170
|
(c) => (
|
|
171
171
|
// 图层文件为GeoJson格式, renderer和symbol使用autocast配置
|
|
172
|
-
new
|
|
172
|
+
new I({
|
|
173
173
|
url: P(c.url, this.mapConfig.assetsRoot),
|
|
174
174
|
...c.options,
|
|
175
175
|
title: c.options.id
|
|
@@ -179,7 +179,7 @@ class ee {
|
|
|
179
179
|
s.addMany(t);
|
|
180
180
|
}
|
|
181
181
|
this.view.ui.remove("attribution"), await this.view.when();
|
|
182
|
-
const
|
|
182
|
+
const g = this.mapConfig.camera;
|
|
183
183
|
let l;
|
|
184
184
|
if (this.view.type === "2d") {
|
|
185
185
|
let t = this.view.center;
|
|
@@ -196,7 +196,7 @@ class ee {
|
|
|
196
196
|
tilt: this.view.camera.tilt
|
|
197
197
|
};
|
|
198
198
|
}
|
|
199
|
-
return
|
|
199
|
+
return g ? g.home = l : this.mapConfig.camera = { home: l }, this.view;
|
|
200
200
|
}
|
|
201
201
|
setLayerVisibility(e) {
|
|
202
202
|
const { id: i, visible: o } = e, r = this.view.map.findLayerById(i);
|
|
@@ -212,14 +212,17 @@ class ee {
|
|
|
212
212
|
if (!this.view)
|
|
213
213
|
return { status: -1, message: "未初始化" };
|
|
214
214
|
if (e.center || e.target) {
|
|
215
|
-
switch ((i = e.target) == null ? void 0 : i.type) {
|
|
215
|
+
switch ((i = e.target) == null ? void 0 : i.type.toLowerCase()) {
|
|
216
216
|
case "point":
|
|
217
217
|
e.target = new T(e.target);
|
|
218
218
|
break;
|
|
219
219
|
case "polyline":
|
|
220
|
-
e.target = new
|
|
220
|
+
e.target = new z(e.target);
|
|
221
221
|
break;
|
|
222
222
|
case "polygon":
|
|
223
|
+
e.target = new W(e.target);
|
|
224
|
+
break;
|
|
225
|
+
case "multipoint":
|
|
223
226
|
e.target = new L(e.target);
|
|
224
227
|
break;
|
|
225
228
|
}
|
|
@@ -248,8 +251,8 @@ class ee {
|
|
|
248
251
|
{ duration: (e.duration || 2) * 1e3 }
|
|
249
252
|
);
|
|
250
253
|
else {
|
|
251
|
-
const r = Math.tan(i * Math.PI / 180) * e.height, s =
|
|
252
|
-
|
|
254
|
+
const r = Math.tan(i * Math.PI / 180) * e.height, s = E(
|
|
255
|
+
A.point(e.center),
|
|
253
256
|
r,
|
|
254
257
|
o + 180,
|
|
255
258
|
{
|
|
@@ -284,14 +287,14 @@ class ee {
|
|
|
284
287
|
* */
|
|
285
288
|
requestCoordinateTransform(e, i) {
|
|
286
289
|
let o = 0;
|
|
287
|
-
const s = 1e3 / 30,
|
|
290
|
+
const s = 1e3 / 30, g = k.watch(
|
|
288
291
|
() => this.view.center,
|
|
289
292
|
() => {
|
|
290
293
|
const l = this.transformPoints(e), p = Date.now();
|
|
291
294
|
p - o > s && (i(l), o = p);
|
|
292
295
|
}
|
|
293
296
|
);
|
|
294
|
-
return this.handleIndex++, this.watchHandleMap.set(this.handleIndex,
|
|
297
|
+
return this.handleIndex++, this.watchHandleMap.set(this.handleIndex, g), { handle: this.handleIndex, points: this.transformPoints(e) };
|
|
295
298
|
}
|
|
296
299
|
transformPoints(e) {
|
|
297
300
|
return e.map((i) => {
|
|
@@ -323,5 +326,5 @@ class ee {
|
|
|
323
326
|
}
|
|
324
327
|
}
|
|
325
328
|
export {
|
|
326
|
-
|
|
329
|
+
te as default
|
|
327
330
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
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;
|