jgis 1.0.3 → 1.0.4
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.
- package/README.md +53 -10
- package/dist/2d/index.js +1 -1
- package/dist/2d/index.mjs +76 -76
- package/dist/2d/interaction.d.ts +2 -2
- package/dist/2d/types.d.ts +2 -2
- package/dist/3d/core.d.ts +2 -2
- package/dist/3d/index.js +1 -1
- package/dist/3d/index.mjs +177 -108
- package/dist/3d/interaction.d.ts +47 -5
- package/dist/3d/layer.d.ts +49 -7
- package/dist/3d/types.d.ts +36 -24
- package/dist/utils/index.d.ts +7 -0
- package/package.json +70 -70
package/dist/3d/index.mjs
CHANGED
|
@@ -1,109 +1,133 @@
|
|
|
1
|
-
var C = Object.defineProperty,
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var C = Object.defineProperty, I = Object.defineProperties;
|
|
2
|
+
var L = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var v = Object.getOwnPropertySymbols;
|
|
4
|
+
var k = Object.prototype.hasOwnProperty, x = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var P = (r, t, e) => t in r ? C(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, m = (r, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
10
|
-
|
|
7
|
+
k.call(t, e) && P(r, e, t[e]);
|
|
8
|
+
if (v)
|
|
9
|
+
for (var e of v(t))
|
|
10
|
+
x.call(t, e) && P(r, e, t[e]);
|
|
11
11
|
return r;
|
|
12
|
-
},
|
|
13
|
-
import * as
|
|
14
|
-
import { getLonLat as
|
|
15
|
-
function
|
|
12
|
+
}, p = (r, t) => I(r, L(t));
|
|
13
|
+
import * as c from "cesium";
|
|
14
|
+
import { getLonLat as b } from "../index.mjs";
|
|
15
|
+
function O(r, t) {
|
|
16
16
|
const e = {
|
|
17
17
|
baseType: "img",
|
|
18
18
|
noteType: "cia",
|
|
19
19
|
token: "dadcbbdb5206b626a29ca739686b3087"
|
|
20
|
-
}, { baseType: a, noteType: n, token: i } = Object.assign(e, t),
|
|
21
|
-
url: `${
|
|
20
|
+
}, { baseType: a, noteType: n, token: i } = Object.assign(e, t), o = "https://t{s}.tianditu.gov.cn", s = ["0", "1", "2", "3", "4", "5", "6", "7"], l = new c.UrlTemplateImageryProvider({
|
|
21
|
+
url: `${o}/DataServer?T=${a}_w&x={x}&y={y}&l={z}&tk=${i}`,
|
|
22
22
|
subdomains: s,
|
|
23
|
-
tilingScheme: new
|
|
23
|
+
tilingScheme: new c.WebMercatorTilingScheme()
|
|
24
24
|
});
|
|
25
|
-
let
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
url: `${
|
|
25
|
+
let u = r.imageryLayers.addImageryProvider(l);
|
|
26
|
+
u.gamma = 1;
|
|
27
|
+
const f = new c.UrlTemplateImageryProvider({
|
|
28
|
+
url: `${o}/DataServer?T=ibo_w&x={x}&y={y}&l={z}&tk=${i}`,
|
|
29
29
|
subdomains: s,
|
|
30
|
-
tilingScheme: new
|
|
30
|
+
tilingScheme: new c.WebMercatorTilingScheme()
|
|
31
31
|
});
|
|
32
|
-
r.imageryLayers.addImageryProvider(
|
|
33
|
-
const
|
|
34
|
-
url: `${
|
|
32
|
+
r.imageryLayers.addImageryProvider(f);
|
|
33
|
+
const M = new c.UrlTemplateImageryProvider({
|
|
34
|
+
url: `${o}/DataServer?T=${n}_w&x={x}&y={y}&l={z}&tk=${i}`,
|
|
35
35
|
subdomains: s,
|
|
36
|
-
tilingScheme: new
|
|
36
|
+
tilingScheme: new c.WebMercatorTilingScheme()
|
|
37
37
|
// maximumLevel: 18
|
|
38
38
|
});
|
|
39
|
-
r.imageryLayers.addImageryProvider(
|
|
39
|
+
r.imageryLayers.addImageryProvider(M);
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
|
|
41
|
+
function B(r, t) {
|
|
42
|
+
O(r, t);
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function w(r, t, e, a) {
|
|
45
45
|
(!a || !a.type) && (a = Object.assign({}, e, a));
|
|
46
46
|
const n = a.type || "Point";
|
|
47
47
|
let i;
|
|
48
48
|
switch (n) {
|
|
49
49
|
case "Point":
|
|
50
|
-
i =
|
|
50
|
+
i = _(r, t, e, a);
|
|
51
51
|
break;
|
|
52
|
+
case "MultiLineString":
|
|
52
53
|
case "LineString":
|
|
53
|
-
i =
|
|
54
|
+
i = E(r, t, e, a);
|
|
55
|
+
break;
|
|
56
|
+
case "Wms":
|
|
57
|
+
e = e || a, i = H(r, t, e);
|
|
54
58
|
break;
|
|
55
59
|
}
|
|
56
60
|
return i;
|
|
57
61
|
}
|
|
58
|
-
function
|
|
59
|
-
const n = r.scene.primitives.add(new
|
|
60
|
-
return n._layerName = t, e.forEach((i,
|
|
62
|
+
function _(r, t, e, a) {
|
|
63
|
+
const n = r.scene.primitives.add(new c.BillboardCollection());
|
|
64
|
+
return n._layerName = t, e.forEach((i, o) => {
|
|
61
65
|
const s = {
|
|
62
66
|
scale: 1,
|
|
63
67
|
// 缩放比例
|
|
64
|
-
verticalOrigin:
|
|
68
|
+
verticalOrigin: c.VerticalOrigin.BOTTOM,
|
|
65
69
|
// 以底部为定位中心
|
|
66
70
|
show: !0,
|
|
67
71
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
68
72
|
// 禁止深度测试距离
|
|
69
|
-
scaleByDistance: new
|
|
73
|
+
scaleByDistance: new c.NearFarScalar(1, 1, 1e5, 0.2)
|
|
70
74
|
// 根据相机距离缩放
|
|
71
75
|
}, l = {
|
|
72
|
-
position:
|
|
73
|
-
image: a.
|
|
74
|
-
id: i.id || `point_${
|
|
75
|
-
},
|
|
76
|
-
|
|
76
|
+
position: c.Cartesian3.fromDegrees(...b(i), 1),
|
|
77
|
+
image: a.image || a.getImage(i),
|
|
78
|
+
id: i.id || `point_${o}`
|
|
79
|
+
}, u = n.add(m(m(m({}, s), a), l));
|
|
80
|
+
u._originStyle = p(m(m(m({}, s), a), l), { color: c.Color.WHITE }), u.properties = i;
|
|
77
81
|
}), r.scene.requestRender(), n;
|
|
78
82
|
}
|
|
79
|
-
function
|
|
83
|
+
function E(r, t, e, a) {
|
|
80
84
|
if (e.length < 2) return;
|
|
81
|
-
const n = D(e, a), i = new
|
|
85
|
+
const n = D(e, a), i = new c.GroundPolylinePrimitive({
|
|
82
86
|
geometryInstances: n,
|
|
83
|
-
appearance: new
|
|
87
|
+
appearance: new c.PolylineColorAppearance({
|
|
84
88
|
translucent: !0
|
|
85
89
|
}),
|
|
86
90
|
interleave: !0,
|
|
87
91
|
allowPicking: !0,
|
|
88
92
|
asynchronous: !1
|
|
89
93
|
});
|
|
90
|
-
i._layerName = t, r.scene.groundPrimitives.add(i);
|
|
94
|
+
return i._layerName = t, r.scene.groundPrimitives.add(i), i;
|
|
91
95
|
}
|
|
92
96
|
function D(r, t) {
|
|
93
|
-
const e = [], a = r.map((
|
|
97
|
+
const e = [], a = r.map((o) => c.Cartesian3.fromDegrees(...b(o), 0)), n = new c.GroundPolylineGeometry({
|
|
94
98
|
positions: a,
|
|
95
99
|
width: t.width || 4,
|
|
96
100
|
granularity: t.granularity || 2e3
|
|
97
|
-
}), i = new
|
|
101
|
+
}), i = new c.GeometryInstance({
|
|
98
102
|
id: "pipeLine",
|
|
99
103
|
geometry: n,
|
|
100
104
|
attributes: {
|
|
101
|
-
color:
|
|
105
|
+
color: c.ColorGeometryInstanceAttribute.fromColor(c.Color.fromCssColorString(t.color))
|
|
102
106
|
}
|
|
103
107
|
});
|
|
104
108
|
return e.push(i), e;
|
|
105
109
|
}
|
|
106
|
-
function
|
|
110
|
+
function H(r, t, e) {
|
|
111
|
+
const a = new c.WebMapServiceImageryProvider({
|
|
112
|
+
url: e.url,
|
|
113
|
+
layers: e.layers,
|
|
114
|
+
parameters: {
|
|
115
|
+
service: "WMS",
|
|
116
|
+
version: "1.1.1",
|
|
117
|
+
request: "GetMap",
|
|
118
|
+
transparent: !0,
|
|
119
|
+
format: "image/png"
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
a._layerName = t;
|
|
123
|
+
const n = r.imageryLayers.addImageryProvider(a);
|
|
124
|
+
return n.alpha = e.alpha || 0.5, n.brightness = e.brightness || 1, n.contrast = e.contrast || 1, n.gamma = e.gamma || 0, n;
|
|
125
|
+
}
|
|
126
|
+
function R(r, t) {
|
|
127
|
+
const e = r.scene.primitives.add(new c.BillboardCollection());
|
|
128
|
+
return e._layerName = t, e;
|
|
129
|
+
}
|
|
130
|
+
function h(r, t) {
|
|
107
131
|
const e = r.scene.primitives, a = e.length;
|
|
108
132
|
for (let n = 0; n < a; n++) {
|
|
109
133
|
const i = e.get(n);
|
|
@@ -112,27 +136,35 @@ function E(r, t) {
|
|
|
112
136
|
}
|
|
113
137
|
return null;
|
|
114
138
|
}
|
|
115
|
-
|
|
116
|
-
|
|
139
|
+
function $(r, t) {
|
|
140
|
+
const e = h(r, t);
|
|
141
|
+
e ? r.scene.primitives.remove(e) : console.warn("Layer not found:", t);
|
|
142
|
+
}
|
|
143
|
+
function N(r, t, e) {
|
|
144
|
+
const a = h(r, t);
|
|
145
|
+
a ? a.show = e : console.warn("Primitive not found:", t);
|
|
146
|
+
}
|
|
147
|
+
const g = /* @__PURE__ */ new Map(), d = {}, y = {}, j = (r, t) => {
|
|
148
|
+
g.has(r) && console.warn(`Map with target '${r}' already exists. Overwriting...`), g.set(r, t), d[r] && (d[r].forEach((e) => e(t)), delete d[r]), y[r] && (y[r].forEach((e) => e(t)), delete y[r]);
|
|
117
149
|
};
|
|
118
|
-
function
|
|
119
|
-
const t =
|
|
150
|
+
function S(r) {
|
|
151
|
+
const t = g.get(r);
|
|
120
152
|
return t ? Promise.resolve(t) : new Promise((e) => {
|
|
121
|
-
|
|
153
|
+
y[r] = y[r] || [], y[r].push(e);
|
|
122
154
|
});
|
|
123
155
|
}
|
|
124
|
-
const
|
|
125
|
-
|
|
156
|
+
const W = (r) => {
|
|
157
|
+
g.has(r) && (g.delete(r), delete d[r]);
|
|
126
158
|
}, T = (r, t) => {
|
|
127
|
-
const e =
|
|
159
|
+
const e = g.get(r);
|
|
128
160
|
if (e) {
|
|
129
161
|
t(e);
|
|
130
162
|
return;
|
|
131
163
|
}
|
|
132
|
-
|
|
164
|
+
d[r] || (d[r] = []), d[r].push(t);
|
|
133
165
|
};
|
|
134
|
-
function
|
|
135
|
-
const e = new
|
|
166
|
+
function q(r, t = {}) {
|
|
167
|
+
const e = new c.Viewer(r, {
|
|
136
168
|
requestRenderMode: !0,
|
|
137
169
|
//减少应用程序的 CPU/GPU 使用率
|
|
138
170
|
maximumRenderTimeChange: 1 / 0,
|
|
@@ -157,29 +189,30 @@ function $(r, t = {}) {
|
|
|
157
189
|
//全屏按钮,默认显示true
|
|
158
190
|
shouldAnimate: !0,
|
|
159
191
|
// Enable animations
|
|
160
|
-
// terrainProvider: _terrainProvider, //地形
|
|
161
192
|
contextOptions: {
|
|
162
193
|
webgl: {
|
|
163
|
-
preserveDrawingBuffer: !0
|
|
194
|
+
preserveDrawingBuffer: !0,
|
|
164
195
|
//允许截图
|
|
196
|
+
alpha: !0
|
|
197
|
+
//允许透明
|
|
165
198
|
}
|
|
166
199
|
}
|
|
167
200
|
});
|
|
168
201
|
let a;
|
|
169
|
-
return
|
|
202
|
+
return c.defined(t.terrainUrl) ? c.CesiumTerrainProvider.fromUrl(t.terrainUrl, {
|
|
170
203
|
requestVertexNormals: !0,
|
|
171
204
|
requestWaterMask: !0
|
|
172
205
|
}).then((n) => {
|
|
173
206
|
a = n, e.terrainProvider = a;
|
|
174
|
-
}) : a = new
|
|
207
|
+
}) : a = new c.EllipsoidTerrainProvider(), e.terrainProvider = a, e._cesiumWidget._creditContainer.style.display = "none", e.scene.globe.baseColor = new c.Color(0, 0, 0, 0), e.scene.screenSpaceCameraController.minimumZoomDistance = t.minZoom || 1, e.scene.screenSpaceCameraController.maximumZoomDistance = t.maxZoom || 1e7, e.resolutionScale = window.devicePixelRatio > 2 ? 2 : window.devicePixelRatio, e;
|
|
175
208
|
}
|
|
176
|
-
function
|
|
177
|
-
|
|
209
|
+
function V(r, t, e, a) {
|
|
210
|
+
w(r, t, e, p(m({}, a), { type: "Point" }));
|
|
178
211
|
}
|
|
179
|
-
function
|
|
212
|
+
function G(r, t, e) {
|
|
180
213
|
return new Promise((a, n) => {
|
|
181
214
|
r.camera.flyTo({
|
|
182
|
-
destination:
|
|
215
|
+
destination: c.Cartesian3.fromDegrees(...t),
|
|
183
216
|
duration: e.duration || 1.2,
|
|
184
217
|
// 飞行动画时间(秒)
|
|
185
218
|
orientation: {
|
|
@@ -187,7 +220,7 @@ function V(r, t, e) {
|
|
|
187
220
|
pitch: e.pitch || -Math.PI / 2,
|
|
188
221
|
roll: e.roll || 0
|
|
189
222
|
},
|
|
190
|
-
easingFunction: e.easing ||
|
|
223
|
+
easingFunction: e.easing || c.EasingFunction.LINEAR_NONE,
|
|
191
224
|
// 飞行动画缓动函数
|
|
192
225
|
maximumHeight: e.maxHeight || 1e6,
|
|
193
226
|
// 相机最大飞行高度
|
|
@@ -200,15 +233,15 @@ function V(r, t, e) {
|
|
|
200
233
|
});
|
|
201
234
|
});
|
|
202
235
|
}
|
|
203
|
-
function
|
|
236
|
+
function U(r, t = 1) {
|
|
204
237
|
return r.camera.flyHome(t);
|
|
205
238
|
}
|
|
206
|
-
function
|
|
239
|
+
function A(r, t, e) {
|
|
207
240
|
return new Promise((a, n) => {
|
|
208
241
|
r.camera.flyToBoundingSphere(t, {
|
|
209
242
|
duration: e.duration || 1e3,
|
|
210
243
|
// 飞行动画时间(秒)
|
|
211
|
-
offset: new
|
|
244
|
+
offset: new c.HeadingPitchRange(e.heading || 0, e.pitch || -Math.PI / 4, e.roll || 0),
|
|
212
245
|
easingFunction: e.easing,
|
|
213
246
|
// 飞行动画缓动函数
|
|
214
247
|
maximumHeight: e.maxHeight || 1e6,
|
|
@@ -222,9 +255,9 @@ function G(r, t, e) {
|
|
|
222
255
|
});
|
|
223
256
|
});
|
|
224
257
|
}
|
|
225
|
-
function
|
|
258
|
+
function F(r, t, e) {
|
|
226
259
|
r.camera.setView({
|
|
227
|
-
destination:
|
|
260
|
+
destination: c.Cartesian3.fromDegrees(...t),
|
|
228
261
|
orientation: {
|
|
229
262
|
heading: e.heading || 0,
|
|
230
263
|
pitch: e.pitch || -Math.PI / 2,
|
|
@@ -232,27 +265,34 @@ function U(r, t, e) {
|
|
|
232
265
|
}
|
|
233
266
|
});
|
|
234
267
|
}
|
|
235
|
-
function
|
|
236
|
-
r.destroy(),
|
|
268
|
+
function Z(r, t) {
|
|
269
|
+
r.destroy(), W(t);
|
|
270
|
+
}
|
|
271
|
+
function z(r, t = 500) {
|
|
272
|
+
let e = 0;
|
|
273
|
+
return function(...a) {
|
|
274
|
+
const n = Date.now();
|
|
275
|
+
n - e >= t && (e = n, r.apply(this, a));
|
|
276
|
+
};
|
|
237
277
|
}
|
|
238
|
-
function
|
|
239
|
-
const e = /* @__PURE__ */ new Set(), a = new
|
|
278
|
+
function K(r, t) {
|
|
279
|
+
const e = /* @__PURE__ */ new Set(), a = new c.ScreenSpaceEventHandler(r.scene.canvas);
|
|
240
280
|
let n = null;
|
|
241
|
-
a.setInputAction((
|
|
242
|
-
const s = r.scene.pick(
|
|
243
|
-
if (n && (Object.assign(n, n._originStyle), n = null, r.scene.requestRender()),
|
|
244
|
-
const l = s.primitive,
|
|
245
|
-
|
|
281
|
+
a.setInputAction((o) => {
|
|
282
|
+
const s = r.scene.pick(o.position);
|
|
283
|
+
if (n && (Object.assign(n, n._originStyle), n = null, r.scene.requestRender()), c.defined(s) && s.primitive instanceof c.Billboard) {
|
|
284
|
+
const l = s.primitive, u = {
|
|
285
|
+
primitive: l,
|
|
246
286
|
properties: l.properties,
|
|
247
|
-
event:
|
|
287
|
+
event: o,
|
|
248
288
|
pick: s
|
|
249
289
|
};
|
|
250
|
-
n = l, i(
|
|
290
|
+
n = l, i(u), Object.assign(l, t.style || t.getStyle(l)), r.scene.requestRender();
|
|
251
291
|
}
|
|
252
|
-
},
|
|
253
|
-
const i = (
|
|
292
|
+
}, c.ScreenSpaceEventType.LEFT_CLICK);
|
|
293
|
+
const i = (o) => e.forEach((s) => s(o));
|
|
254
294
|
return {
|
|
255
|
-
onSelect: (
|
|
295
|
+
onSelect: (o) => (e.add(o), () => e.delete(o)),
|
|
256
296
|
clear() {
|
|
257
297
|
e.clear();
|
|
258
298
|
},
|
|
@@ -261,34 +301,63 @@ function F(r, t) {
|
|
|
261
301
|
}
|
|
262
302
|
};
|
|
263
303
|
}
|
|
264
|
-
function
|
|
265
|
-
const e =
|
|
266
|
-
|
|
304
|
+
function Y(r, t) {
|
|
305
|
+
const e = /* @__PURE__ */ new Set(), a = (s) => e.forEach((l) => l(s)), n = new c.ScreenSpaceEventHandler(r.scene.canvas);
|
|
306
|
+
let i = null;
|
|
307
|
+
const o = z(a, t.delay || 500);
|
|
308
|
+
return n.setInputAction((s) => {
|
|
309
|
+
const l = r.scene.pick(s.endPosition);
|
|
310
|
+
if (i && (Object.assign(i, i._originStyle), i = null, r.scene.requestRender()), c.defined(l) && l.primitive instanceof c.Billboard) {
|
|
311
|
+
const u = l.primitive, f = {
|
|
312
|
+
primitive: u,
|
|
313
|
+
properties: u.properties,
|
|
314
|
+
event: s,
|
|
315
|
+
pick: l
|
|
316
|
+
};
|
|
317
|
+
o(f), i = u, Object.assign(u, t.style || t.getStyle(u)), r.scene.requestRender();
|
|
318
|
+
}
|
|
319
|
+
}, c.ScreenSpaceEventType.MOUSE_MOVE), {
|
|
320
|
+
onHover: (s) => (e.add(s), () => e.delete(s)),
|
|
321
|
+
clear: () => {
|
|
322
|
+
e.clear();
|
|
323
|
+
},
|
|
324
|
+
destroy: () => {
|
|
325
|
+
e.clear();
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
function X(r, t) {
|
|
330
|
+
const e = q(r, t);
|
|
331
|
+
B(e, t);
|
|
267
332
|
const a = {
|
|
268
333
|
targetId: r,
|
|
269
334
|
instance: e,
|
|
270
|
-
addMarker: (n, i,
|
|
271
|
-
createLayer: (n, i,
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
335
|
+
addMarker: (n, i, o) => V(e, n, i, o),
|
|
336
|
+
createLayer: (n, i, o) => w(e, n, i, o),
|
|
337
|
+
removeLayer: (n) => $(e, n),
|
|
338
|
+
visibleLayer: (n, i) => N(e, n, i),
|
|
339
|
+
getLayerByName: (n) => h(e, n),
|
|
340
|
+
createBlankLayer: (n) => R(e, n),
|
|
341
|
+
createSelect: (n) => K(e, n),
|
|
342
|
+
createHover: (n) => Y(e, n),
|
|
343
|
+
flyTo: (n, i) => G(e, n, i),
|
|
344
|
+
flyHome: (n) => U(e, n),
|
|
345
|
+
flyToBoundingSphere: (n, i) => A(e, n, i),
|
|
346
|
+
setView: (n, i) => F(e, n, i),
|
|
347
|
+
getMapContext: (n) => S(n),
|
|
279
348
|
onMapReady: (n, i) => T(n, i),
|
|
280
|
-
destroyMap: (n) =>
|
|
349
|
+
destroyMap: (n) => Z(e, n)
|
|
281
350
|
};
|
|
282
|
-
return
|
|
351
|
+
return j(r, a), a;
|
|
283
352
|
}
|
|
284
|
-
function
|
|
353
|
+
function ee(r, t) {
|
|
285
354
|
T(r, t);
|
|
286
355
|
}
|
|
287
|
-
function
|
|
288
|
-
return
|
|
356
|
+
function re(r) {
|
|
357
|
+
return S(r);
|
|
289
358
|
}
|
|
290
359
|
export {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
360
|
+
re as getMapContext,
|
|
361
|
+
ee as onMapReady,
|
|
362
|
+
X as useMap
|
|
294
363
|
};
|
package/dist/3d/interaction.d.ts
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { billboardOptions } from './types';
|
|
2
|
+
import * as Cesium from 'cesium';
|
|
3
|
+
export interface SelectResult {
|
|
4
|
+
primitive: Cesium.Primitive;
|
|
5
|
+
properties: any;
|
|
6
|
+
event: Cesium.Cartesian2;
|
|
7
|
+
pick: any;
|
|
8
|
+
}
|
|
9
|
+
export interface UseSelectResult {
|
|
10
|
+
onSelect: (result: (SelectResult: any) => void) => void;
|
|
11
|
+
clear: () => void;
|
|
12
|
+
destroy: () => void;
|
|
13
|
+
}
|
|
14
|
+
export interface SelectOptions {
|
|
15
|
+
style?: billboardOptions;
|
|
16
|
+
getStyle?: (primitive: Cesium.Primitive) => billboardOptions;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 创建选择功能
|
|
20
|
+
* @param {Cesium.Viewer} viewer 视图
|
|
21
|
+
* @param {SelectOptions} options 配置项
|
|
22
|
+
* @returns {UseSelectResult}
|
|
23
|
+
*/
|
|
24
|
+
export declare function createSelect(viewer: Cesium.Viewer, options: SelectOptions): UseSelectResult;
|
|
25
|
+
export interface HoverEvent {
|
|
26
|
+
primitive: Cesium.Primitive;
|
|
27
|
+
properties: any;
|
|
28
|
+
event: Cesium.Cartesian2;
|
|
29
|
+
pick: any;
|
|
30
|
+
}
|
|
31
|
+
export interface HoverOptions {
|
|
32
|
+
delay?: number;
|
|
33
|
+
style?: billboardOptions;
|
|
34
|
+
getStyle?: (primitive: Cesium.Primitive) => billboardOptions;
|
|
35
|
+
}
|
|
36
|
+
export interface UseHoverResult {
|
|
37
|
+
onHover: (result: (HoverEvent: any) => void) => void;
|
|
38
|
+
clear: () => void;
|
|
39
|
+
destroy: () => void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 创建hover事件
|
|
43
|
+
* @param {Cesium.Viewer} viewer 视图
|
|
44
|
+
* @param {HoverOptions} options 配置项
|
|
45
|
+
* @returns {UseHoverResult}
|
|
46
|
+
*/
|
|
47
|
+
export declare function createHover(viewer: Cesium.Viewer, options: HoverOptions): UseHoverResult;
|
package/dist/3d/layer.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WmsOptions, optionsMap } from './types';
|
|
1
2
|
import * as Cesium from 'cesium';
|
|
2
3
|
/**
|
|
3
4
|
* 初始化地图
|
|
@@ -13,7 +14,9 @@ export declare function createBaseLayer(viewer: Cesium.Viewer, options: any): vo
|
|
|
13
14
|
* @param options 配置项
|
|
14
15
|
* @returns 图层
|
|
15
16
|
*/
|
|
16
|
-
export declare function createLayer(viewer: Cesium.Viewer, layerName: string, data: any, options:
|
|
17
|
+
export declare function createLayer<K extends keyof optionsMap>(viewer: Cesium.Viewer, layerName: string, data: any, options: optionsMap[K] & {
|
|
18
|
+
type?: K;
|
|
19
|
+
}): any;
|
|
17
20
|
/**
|
|
18
21
|
* 创建点图层
|
|
19
22
|
* @param viewer 视图
|
|
@@ -21,9 +24,48 @@ export declare function createLayer(viewer: Cesium.Viewer, layerName: string, da
|
|
|
21
24
|
* @param data 数据
|
|
22
25
|
* @param options 配置项
|
|
23
26
|
*/
|
|
24
|
-
export declare function createPointLayer(viewer: Cesium.Viewer, layerName: string, data: any[], options: Cesium.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
export declare function createPointLayer(viewer: Cesium.Viewer, layerName: string, data: any[], options: optionsMap['Point']): Cesium.BillboardCollection;
|
|
28
|
+
/**
|
|
29
|
+
* 创建线图层
|
|
30
|
+
* @param viewer 视图
|
|
31
|
+
* @param layerName 图层名称
|
|
32
|
+
* @param data 数据
|
|
33
|
+
* @param options 配置项
|
|
34
|
+
* @returns {Cesium.GroundPolylinePrimitive}
|
|
35
|
+
*/
|
|
36
|
+
export declare function createLineLayer(viewer: any, layerName: string, data: any[], options: optionsMap['LineString']): Cesium.GroundPolylinePrimitive;
|
|
37
|
+
/**
|
|
38
|
+
* 创建wms图层
|
|
39
|
+
* @param viewer 视图
|
|
40
|
+
* @param layerName 图层名称
|
|
41
|
+
* @param options 配置项
|
|
42
|
+
* @returns {Cesium.ImageryLayer}
|
|
43
|
+
*/
|
|
44
|
+
export declare function createWmsLayer(viewer: Cesium.Viewer, layerName: string, options: WmsOptions): Cesium.ImageryLayer;
|
|
45
|
+
/**
|
|
46
|
+
* 创建空白图层
|
|
47
|
+
* @param viewer 视图
|
|
48
|
+
* @param layerName 图层名称
|
|
49
|
+
* @returns {Cesium.DataSource}
|
|
50
|
+
*/
|
|
51
|
+
export declare function createBlankLayer(viewer: Cesium.Viewer, layerName: string): Cesium.Primitive;
|
|
52
|
+
/**
|
|
53
|
+
* 根据图层名获取图层
|
|
54
|
+
* @param viewer 视图
|
|
55
|
+
* @param layerName 图层名
|
|
56
|
+
* @returns {Primitive} 图层
|
|
57
|
+
*/
|
|
58
|
+
export declare function getLayerByName(viewer: Cesium.Viewer, layerName: string): Cesium.Primitive;
|
|
59
|
+
/**
|
|
60
|
+
* 删除图层
|
|
61
|
+
* @param viewer 视图
|
|
62
|
+
* @param layerName 图层名
|
|
63
|
+
*/
|
|
64
|
+
export declare function removeLayer(viewer: any, layerName: any): void;
|
|
65
|
+
/**
|
|
66
|
+
* 隐藏图层
|
|
67
|
+
* @param {Cesium.Viewer} viewer 视图
|
|
68
|
+
* @param {string} layerName 图层名
|
|
69
|
+
* @param {boolean} visible 图层名
|
|
70
|
+
*/
|
|
71
|
+
export declare function visibleLayer(viewer: Cesium.Viewer, layerName: string, visible: boolean): void;
|
package/dist/3d/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { HoverOptions, SelectOptions, UseHoverResult, UseSelectResult } from './interaction';
|
|
1
2
|
import * as Cesium from 'cesium';
|
|
2
3
|
export interface flyOptions {
|
|
3
4
|
heading?: number;
|
|
@@ -16,41 +17,52 @@ export interface LayerOptions {
|
|
|
16
17
|
opacity?: number;
|
|
17
18
|
interactive?: boolean;
|
|
18
19
|
}
|
|
19
|
-
export interface
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
export interface WmsOptions {
|
|
21
|
+
url: string;
|
|
22
|
+
layers?: string;
|
|
23
|
+
alpha?: number;
|
|
24
|
+
brightness?: number;
|
|
25
|
+
gamma?: number;
|
|
26
|
+
contrast?: number;
|
|
24
27
|
}
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
export type ILineOptions = {
|
|
29
|
+
width: number;
|
|
30
|
+
color: string;
|
|
31
|
+
material: Cesium.Material;
|
|
32
|
+
granularity: number;
|
|
33
|
+
};
|
|
34
|
+
export interface optionsMap {
|
|
35
|
+
Point: billboardOptions & {
|
|
36
|
+
getImage?: Function;
|
|
37
|
+
};
|
|
38
|
+
LineString: ILineOptions;
|
|
39
|
+
MultiLineString: ILineOptions;
|
|
40
|
+
Polygon: any;
|
|
41
|
+
MultiPolygon: any;
|
|
42
|
+
Circle: any;
|
|
43
|
+
Wms: WmsOptions;
|
|
44
|
+
Overlay: any;
|
|
29
45
|
}
|
|
46
|
+
export type billboardOptions = Omit<Cesium.Billboard.ConstructorOptions, 'position'>;
|
|
30
47
|
export type Coordinates = [number, number, number];
|
|
31
48
|
export interface MapContext {
|
|
32
49
|
targetId: string;
|
|
33
50
|
instance: Cesium.Viewer;
|
|
34
|
-
addMarker: (layerName: string, data: any, options?:
|
|
35
|
-
createLayer: (layerName: string, data: any, options?:
|
|
51
|
+
addMarker: (layerName: string, data: any, options?: optionsMap['Point']) => void;
|
|
52
|
+
createLayer: <K extends keyof optionsMap>(layerName: string, data: any, options?: optionsMap[K] & {
|
|
53
|
+
type?: K;
|
|
54
|
+
}) => Cesium.Primitive;
|
|
36
55
|
removeLayer: (layerName: string) => void;
|
|
37
|
-
visibleLayer: (layerName: string, visible: boolean) =>
|
|
38
|
-
getLayerByName: (layerName: string) =>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
lightFeature: (layerName: string, feature: FeatureLike, options: HighLightOptions, zoomFlag: boolean) => void;
|
|
43
|
-
flashFeature: (layerName: string, feature: FeatureLike & customFeature, options: FlashOptions) => void;
|
|
44
|
-
queryFeature: (layerName: string, properties: any) => FeatureLike;
|
|
45
|
-
useSelect: (options: any) => UseSelectResult;
|
|
46
|
-
useHover: (options: HoverOptions) => UseHoverResult;
|
|
56
|
+
visibleLayer: (layerName: string, visible: boolean) => void;
|
|
57
|
+
getLayerByName: (layerName: string) => Cesium.Primitive;
|
|
58
|
+
createBlankLayer: (layerName: string, options: LayerOptions) => Cesium.Primitive;
|
|
59
|
+
createSelect: (options: SelectOptions) => UseSelectResult;
|
|
60
|
+
createHover: (options: HoverOptions) => UseHoverResult;
|
|
47
61
|
flyTo: (coordinate: Coordinates, options: flyOptions) => Promise<boolean>;
|
|
48
62
|
flyHome: (duration?: number) => void;
|
|
49
63
|
flyToBoundingSphere: (boundingSphere: Cesium.BoundingSphere, options?: flyOptions) => Promise<boolean>;
|
|
50
|
-
getProjection: () => void;
|
|
51
|
-
getZoom: () => number;
|
|
52
64
|
setView: (coordinate: Coordinates, options?: flyOptions) => void;
|
|
53
65
|
getMapContext: (id: string) => Promise<MapContext>;
|
|
54
|
-
onMapReady: (id: string, callback: () => void) => void;
|
|
66
|
+
onMapReady: (id: string, callback: (cxt: MapContext) => void) => void;
|
|
55
67
|
destroyMap: (id: string) => void;
|
|
56
68
|
}
|