jgis 1.0.2 → 1.0.3
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 +119 -16
- package/dist/2d/index.d.ts +1 -1
- package/dist/2d/index.js +1 -1
- package/dist/2d/index.mjs +106 -100
- package/dist/2d/types.d.ts +7 -6
- package/dist/2d/utils.d.ts +4 -1
- package/dist/3d/core.d.ts +39 -8
- package/dist/3d/index.d.ts +20 -4
- package/dist/3d/index.js +1 -1
- package/dist/3d/index.mjs +251 -77
- package/dist/3d/interaction.d.ts +5 -0
- package/dist/3d/layer.d.ts +29 -0
- package/dist/3d/store.d.ts +16 -0
- package/dist/3d/types.d.ts +56 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +7 -3
- package/dist/utils/index.d.ts +0 -0
- package/package.json +1 -1
- package/dist/2d/index2.d.ts +0 -23
package/dist/2d/index.mjs
CHANGED
|
@@ -27,17 +27,18 @@ var T = (e, t, r) => new Promise((o, n) => {
|
|
|
27
27
|
c((r = r.apply(e, t)).next());
|
|
28
28
|
});
|
|
29
29
|
import { Map as ue, View as fe } from "ol";
|
|
30
|
-
import { Tile as
|
|
31
|
-
import { Vector as
|
|
30
|
+
import { Tile as j, Vector as E } from "ol/layer";
|
|
31
|
+
import { Vector as M, TileWMS as N, XYZ as G, ImageWMS as W } from "ol/source";
|
|
32
32
|
import { GeoJSON as I } from "ol/format";
|
|
33
33
|
import ye from "ol/Overlay";
|
|
34
34
|
import { Geometry as ge, Polygon as me, MultiPolygon as de, MultiLineString as we, LineString as he, Point as be } from "ol/geom";
|
|
35
35
|
import Le from "ol/Feature";
|
|
36
36
|
import "ol/extent";
|
|
37
37
|
import { Style as Fe, Circle as Se, Fill as xe } from "ol/style";
|
|
38
|
-
import {
|
|
39
|
-
import
|
|
40
|
-
|
|
38
|
+
import { defaults as Pe } from "ol/control";
|
|
39
|
+
import { click as ve } from "ol/events/condition.js";
|
|
40
|
+
import Ee from "ol/interaction/Select";
|
|
41
|
+
var g = 63710088e-1, Me = {
|
|
41
42
|
centimeters: g * 100,
|
|
42
43
|
centimetres: g * 100,
|
|
43
44
|
degrees: 360 / (2 * Math.PI),
|
|
@@ -72,7 +73,7 @@ function q(e, t, r = {}) {
|
|
|
72
73
|
coordinates: e
|
|
73
74
|
}, t, r);
|
|
74
75
|
}
|
|
75
|
-
function
|
|
76
|
+
function Te(e, t, r = {}) {
|
|
76
77
|
for (const n of e) {
|
|
77
78
|
if (n.length < 4)
|
|
78
79
|
throw new Error(
|
|
@@ -89,8 +90,8 @@ function ve(e, t, r = {}) {
|
|
|
89
90
|
coordinates: e
|
|
90
91
|
}, t, r);
|
|
91
92
|
}
|
|
92
|
-
function
|
|
93
|
-
const r =
|
|
93
|
+
function Ie(e, t = "kilometers") {
|
|
94
|
+
const r = Me[t];
|
|
94
95
|
if (!r)
|
|
95
96
|
throw new Error(t + " units is invalid");
|
|
96
97
|
return e / r;
|
|
@@ -104,7 +105,7 @@ function z(e) {
|
|
|
104
105
|
function D(e) {
|
|
105
106
|
return !isNaN(e) && e !== null && !Array.isArray(e);
|
|
106
107
|
}
|
|
107
|
-
function
|
|
108
|
+
function pe(e) {
|
|
108
109
|
if (!e)
|
|
109
110
|
throw new Error("coord is required");
|
|
110
111
|
if (!Array.isArray(e)) {
|
|
@@ -117,8 +118,8 @@ function Ie(e) {
|
|
|
117
118
|
return [...e];
|
|
118
119
|
throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
|
119
120
|
}
|
|
120
|
-
function
|
|
121
|
-
const n =
|
|
121
|
+
function Ae(e, t, r, o = {}) {
|
|
122
|
+
const n = pe(e), s = z(n[0]), a = z(n[1]), c = z(r), i = Ie(t, o.units), l = Math.asin(
|
|
122
123
|
Math.sin(a) * Math.cos(i) + Math.cos(a) * Math.sin(i) * Math.cos(c)
|
|
123
124
|
), m = s + Math.atan2(
|
|
124
125
|
Math.sin(c) * Math.sin(i) * Math.cos(a),
|
|
@@ -126,16 +127,16 @@ function pe(e, t, r, o = {}) {
|
|
|
126
127
|
), x = $(m), u = $(l);
|
|
127
128
|
return n[2] !== void 0 ? q([x, u, n[2]], o.properties) : q([x, u], o.properties);
|
|
128
129
|
}
|
|
129
|
-
function
|
|
130
|
+
function ke(e, t, r = {}) {
|
|
130
131
|
const o = r.steps || 64, n = r.properties ? r.properties : !Array.isArray(e) && e.type === "Feature" && e.properties ? e.properties : {}, s = [];
|
|
131
132
|
for (let a = 0; a < o; a++)
|
|
132
133
|
s.push(
|
|
133
|
-
|
|
134
|
+
Ae(e, t, a * -360 / o, r).geometry.coordinates
|
|
134
135
|
);
|
|
135
|
-
return s.push(s[0]),
|
|
136
|
+
return s.push(s[0]), Te([s], n);
|
|
136
137
|
}
|
|
137
|
-
function p(e) {
|
|
138
|
-
return e.lttd && e.lgtd ? [Number(e.lgtd), Number(e.lttd)] : e.jd && e.wd ? [Number(e.jd), Number(e.wd)] : e.latitude && e.longitude ? [Number(e.longitude), Number(e.latitude)] : e.lon && e.lat ? [Number(e.lon), Number(e.lat)] :
|
|
138
|
+
function p(e, t) {
|
|
139
|
+
return typeof e != "object" || e === null ? null : e.lttd && e.lgtd ? [Number(e.lgtd), Number(e.lttd)] : e.jd && e.wd ? [Number(e.jd), Number(e.wd)] : e.latitude && e.longitude ? [Number(e.longitude), Number(e.latitude)] : e.lon && e.lat ? [Number(e.lon), Number(e.lat)] : null;
|
|
139
140
|
}
|
|
140
141
|
function U(e, t) {
|
|
141
142
|
e.getLayers().getArray().forEach((o) => {
|
|
@@ -146,7 +147,7 @@ function J(e, t, r, o = !1) {
|
|
|
146
147
|
const n = o ? r.style || r.getStyle(e, t) : void 0, s = o ? 999 : -1;
|
|
147
148
|
n && typeof n.setZIndex == "function" && n.setZIndex(s), t.setStyle(n);
|
|
148
149
|
}
|
|
149
|
-
function
|
|
150
|
+
function Re(e, t, r) {
|
|
150
151
|
if (!t) return;
|
|
151
152
|
const o = r.time || 300;
|
|
152
153
|
let n = Date.now(), s = !1, a = 0;
|
|
@@ -160,7 +161,7 @@ function ke(e, t, r) {
|
|
|
160
161
|
t.running = !1, cancelAnimationFrame(a), t.setStyle(void 0);
|
|
161
162
|
};
|
|
162
163
|
}
|
|
163
|
-
function
|
|
164
|
+
function Oe(e, t, r) {
|
|
164
165
|
var a, c;
|
|
165
166
|
if (!r) return;
|
|
166
167
|
let o = p(r);
|
|
@@ -170,7 +171,7 @@ function Re(e, t, r) {
|
|
|
170
171
|
return l && l instanceof ge && typeof l.intersectsCoordinate == "function" ? l.intersectsCoordinate(o) : !1;
|
|
171
172
|
}) : void 0;
|
|
172
173
|
}
|
|
173
|
-
function
|
|
174
|
+
function ze(e, t, r) {
|
|
174
175
|
const o = [];
|
|
175
176
|
let n;
|
|
176
177
|
const s = r.type || "Point";
|
|
@@ -180,16 +181,16 @@ function Oe(e, t, r) {
|
|
|
180
181
|
n = Ne(c);
|
|
181
182
|
break;
|
|
182
183
|
case "LineString":
|
|
183
|
-
n =
|
|
184
|
+
n = Ze(c);
|
|
184
185
|
break;
|
|
185
186
|
case "MultiLineString":
|
|
186
|
-
n =
|
|
187
|
+
n = _e(c);
|
|
187
188
|
break;
|
|
188
189
|
case "MultiPolygon":
|
|
189
|
-
n =
|
|
190
|
+
n = Ce(c);
|
|
190
191
|
break;
|
|
191
192
|
case "Polygon":
|
|
192
|
-
n =
|
|
193
|
+
n = Be(c);
|
|
193
194
|
break;
|
|
194
195
|
}
|
|
195
196
|
if (!n) return;
|
|
@@ -199,11 +200,11 @@ function Oe(e, t, r) {
|
|
|
199
200
|
});
|
|
200
201
|
i.set("layerName", e), o.push(i);
|
|
201
202
|
});
|
|
202
|
-
const a = new
|
|
203
|
+
const a = new M();
|
|
203
204
|
return o.length > 0 && a.addFeatures(o), a;
|
|
204
205
|
}
|
|
205
|
-
function
|
|
206
|
-
return t.cqlFilter && (t.cqlFilter ? t.CQL_FILTER += ` and ${t.cqlFilter}` : t.CQL_FILTER = t.cqlFilter), new
|
|
206
|
+
function je(e, t) {
|
|
207
|
+
return t.cqlFilter && (t.cqlFilter ? t.CQL_FILTER += ` and ${t.cqlFilter}` : t.CQL_FILTER = t.cqlFilter), new N({
|
|
207
208
|
url: t.url,
|
|
208
209
|
params: {
|
|
209
210
|
LAYERS: t.layers,
|
|
@@ -222,23 +223,23 @@ function Ne(e) {
|
|
|
222
223
|
if (t)
|
|
223
224
|
return new be(t);
|
|
224
225
|
}
|
|
225
|
-
function
|
|
226
|
+
function Ze(e) {
|
|
226
227
|
return new he(e.coordinates);
|
|
227
228
|
}
|
|
228
|
-
function
|
|
229
|
+
function _e(e) {
|
|
229
230
|
return new we(e.coordinates);
|
|
230
231
|
}
|
|
231
|
-
function
|
|
232
|
+
function Ce(e) {
|
|
232
233
|
return new de(e.coordinates);
|
|
233
234
|
}
|
|
234
|
-
function
|
|
235
|
+
function Be(e) {
|
|
235
236
|
return new me(e.coordinates);
|
|
236
237
|
}
|
|
237
238
|
function A(e, t) {
|
|
238
239
|
let r = null;
|
|
239
|
-
return t.style ? r = t.style : t.getStyle ? r = (o, n) => t.getStyle(e, o, n) : r =
|
|
240
|
+
return t.style ? r = t.style : t.getStyle ? r = (o, n) => t.getStyle(e, o, n) : r = Ve(), r;
|
|
240
241
|
}
|
|
241
|
-
function
|
|
242
|
+
function Ve() {
|
|
242
243
|
return (t, r) => new Fe({
|
|
243
244
|
image: new Se({
|
|
244
245
|
radius: 5,
|
|
@@ -246,8 +247,8 @@ function Be() {
|
|
|
246
247
|
})
|
|
247
248
|
});
|
|
248
249
|
}
|
|
249
|
-
function
|
|
250
|
-
const r = t.token || "dadcbbdb5206b626a29ca739686b3087", o = t.baseType || "img", n = t.noteType || "cia", s = new
|
|
250
|
+
function Ge(e, t = {}) {
|
|
251
|
+
const r = t.token || "dadcbbdb5206b626a29ca739686b3087", o = t.baseType || "img", n = t.noteType || "cia", s = new j({
|
|
251
252
|
className: "tdt-base-layer",
|
|
252
253
|
source: new G({
|
|
253
254
|
url: `http://t0.tianditu.com/DataServer?T=${o}_w&x={x}&y={y}&l={z}&tk=${r}`,
|
|
@@ -257,7 +258,7 @@ function Ve(e, t = {}) {
|
|
|
257
258
|
zIndex: t.zIndex || 1
|
|
258
259
|
});
|
|
259
260
|
s.set("name", "tdt-base-layer");
|
|
260
|
-
const a = new
|
|
261
|
+
const a = new j({
|
|
261
262
|
className: "tdt-base-layer",
|
|
262
263
|
source: new G({
|
|
263
264
|
url: `http://t0.tianditu.com/DataServer?T=${n}_w&x={x}&y={y}&l={z}&tk=${r}`,
|
|
@@ -274,39 +275,39 @@ function X(e, t, r, o) {
|
|
|
274
275
|
let s;
|
|
275
276
|
switch (n) {
|
|
276
277
|
case "GeoJSON":
|
|
277
|
-
s =
|
|
278
|
+
s = $e(t, r, e, o);
|
|
278
279
|
break;
|
|
279
280
|
case "Wms":
|
|
280
|
-
s =
|
|
281
|
+
s = De(t, e, o);
|
|
281
282
|
break;
|
|
282
283
|
case "Point":
|
|
283
284
|
case "LineString":
|
|
284
285
|
case "MultiLineString":
|
|
285
286
|
case "Polygon":
|
|
286
287
|
case "MultiPolygon":
|
|
287
|
-
s =
|
|
288
|
+
s = Ue(t, r, e, o);
|
|
288
289
|
break;
|
|
289
290
|
case "Circle":
|
|
290
|
-
s =
|
|
291
|
+
s = We(t, r, e, o);
|
|
291
292
|
break;
|
|
292
293
|
case "Overlay":
|
|
293
|
-
s =
|
|
294
|
+
s = He(t, e, o);
|
|
294
295
|
break;
|
|
295
296
|
}
|
|
296
297
|
return s;
|
|
297
298
|
}
|
|
298
|
-
function
|
|
299
|
+
function qe(e, t) {
|
|
299
300
|
Array.isArray(t) ? t.forEach((r) => {
|
|
300
301
|
U(e, r);
|
|
301
302
|
}) : U(e, t);
|
|
302
303
|
}
|
|
303
|
-
function
|
|
304
|
+
function $e(e, t, r, o) {
|
|
304
305
|
console.log(typeof t, t);
|
|
305
306
|
const n = new I().readFeatures(t, {
|
|
306
307
|
dataProjection: "EPSG:4326",
|
|
307
308
|
featureProjection: "EPSG:4326"
|
|
308
309
|
// 或 'EPSG:3857',看你的地图
|
|
309
|
-
}), s = new
|
|
310
|
+
}), s = new M();
|
|
310
311
|
s.addFeatures(n);
|
|
311
312
|
const a = new E({
|
|
312
313
|
source: s,
|
|
@@ -315,28 +316,28 @@ function qe(e, t, r, o) {
|
|
|
315
316
|
});
|
|
316
317
|
return a.set("name", e), a.set("type", "webgl"), r.addLayer(a), a;
|
|
317
318
|
}
|
|
318
|
-
function
|
|
319
|
-
const o = new
|
|
319
|
+
function De(e, t, r) {
|
|
320
|
+
const o = new j({
|
|
320
321
|
opacity: r.opacity || 1,
|
|
321
|
-
source:
|
|
322
|
+
source: je(e, r),
|
|
322
323
|
zIndex: r.zIndex || 10
|
|
323
324
|
});
|
|
324
325
|
return o.set("name", e), t.addLayer(o), o;
|
|
325
326
|
}
|
|
326
|
-
function
|
|
327
|
+
function Ue(e, t, r, o) {
|
|
327
328
|
if (!t || t.length === 0) return null;
|
|
328
329
|
const n = new E({
|
|
329
|
-
source:
|
|
330
|
+
source: ze(e, t, o),
|
|
330
331
|
style: A(e, o),
|
|
331
332
|
zIndex: o.zIndex || 10
|
|
332
333
|
});
|
|
333
334
|
return n.set("name", e), n.set("type", "webgl"), r.addLayer(n), n;
|
|
334
335
|
}
|
|
335
|
-
function
|
|
336
|
-
const n = p(t), s =
|
|
336
|
+
function We(e, t, r, o) {
|
|
337
|
+
const n = p(t), s = ke(n, o.radius, { steps: 300, units: "meters" }), a = new I().readFeature(s, {
|
|
337
338
|
dataProjection: "EPSG:4326",
|
|
338
339
|
featureProjection: "EPSG:4490"
|
|
339
|
-
}), c = new
|
|
340
|
+
}), c = new M({ wrapX: !1 });
|
|
340
341
|
c.addFeature(a);
|
|
341
342
|
const i = new E({
|
|
342
343
|
source: c,
|
|
@@ -345,7 +346,7 @@ function Ue(e, t, r, o) {
|
|
|
345
346
|
});
|
|
346
347
|
return i.set("name", e), i.set("type", "webgl"), r.addLayer(i), i;
|
|
347
348
|
}
|
|
348
|
-
function
|
|
349
|
+
function He(e, t, r) {
|
|
349
350
|
const o = document.createElement("div"), n = new ye({
|
|
350
351
|
element: o,
|
|
351
352
|
stopEvent: !1,
|
|
@@ -353,9 +354,9 @@ function We(e, t, r) {
|
|
|
353
354
|
});
|
|
354
355
|
return n.set("name", e), n.set("type", "webgl"), t.addOverlay(n), { overlayer: n, content: o };
|
|
355
356
|
}
|
|
356
|
-
function
|
|
357
|
+
function Je(e, t, r) {
|
|
357
358
|
const o = new E({
|
|
358
|
-
source: new
|
|
359
|
+
source: new M({ wrapX: !1 }),
|
|
359
360
|
zIndex: r.zIndex ? r.zIndex : 10,
|
|
360
361
|
style: A(t, r)
|
|
361
362
|
});
|
|
@@ -364,32 +365,32 @@ function He(e, t, r) {
|
|
|
364
365
|
function Z(e, t) {
|
|
365
366
|
return e.getAllLayers().find((n) => n.get("name") === t);
|
|
366
367
|
}
|
|
367
|
-
function
|
|
368
|
+
function Qe(e, t, r) {
|
|
368
369
|
const o = Z(e, t);
|
|
369
370
|
return o.setVisible(r), o;
|
|
370
371
|
}
|
|
371
|
-
const
|
|
372
|
-
|
|
372
|
+
const v = /* @__PURE__ */ new Map(), S = {}, P = {}, Xe = (e, t) => {
|
|
373
|
+
v.has(e) && console.warn(`Map with target '${e}' already exists. Overwriting...`), v.set(e, t), S[e] && (S[e].forEach((r) => r(t)), delete S[e]), P[e] && (P[e].forEach((r) => r(t)), delete P[e]);
|
|
373
374
|
};
|
|
374
375
|
function Y(e) {
|
|
375
|
-
const t =
|
|
376
|
-
return t ? Promise.resolve(t) :
|
|
377
|
-
|
|
378
|
-
})
|
|
376
|
+
const t = v.get(e);
|
|
377
|
+
return t ? Promise.resolve(t) : new Promise((r) => {
|
|
378
|
+
P[e] = P[e] || [], P[e].push(r);
|
|
379
|
+
});
|
|
379
380
|
}
|
|
380
|
-
const
|
|
381
|
-
|
|
381
|
+
const Ye = (e) => {
|
|
382
|
+
v.has(e) && (v.delete(e), delete S[e]);
|
|
382
383
|
}, K = (e, t) => {
|
|
383
|
-
const r =
|
|
384
|
+
const r = v.get(e);
|
|
384
385
|
if (r) {
|
|
385
386
|
t(r);
|
|
386
387
|
return;
|
|
387
388
|
}
|
|
388
389
|
S[e] || (S[e] = []), S[e].push(t);
|
|
389
390
|
};
|
|
390
|
-
function
|
|
391
|
+
function Ke(e, t = {}) {
|
|
391
392
|
if (!e && !e.target)
|
|
392
|
-
throw new Error("
|
|
393
|
+
throw new Error("is not a valid element");
|
|
393
394
|
arguments.length === 1 && typeof e == "object" && (t = e, e = t.target);
|
|
394
395
|
const o = Object.assign({
|
|
395
396
|
zoom: 10,
|
|
@@ -413,11 +414,16 @@ function Ye(e, t = {}) {
|
|
|
413
414
|
zoom: o.zoom,
|
|
414
415
|
minZoom: o.minZoom,
|
|
415
416
|
maxZoom: o.maxZoom
|
|
417
|
+
}),
|
|
418
|
+
controls: Pe({
|
|
419
|
+
zoom: !1,
|
|
420
|
+
rotate: !1,
|
|
421
|
+
attribution: !1
|
|
416
422
|
})
|
|
417
423
|
});
|
|
418
424
|
return n.targetId = e, n;
|
|
419
425
|
}
|
|
420
|
-
function
|
|
426
|
+
function et(e, t, r, o) {
|
|
421
427
|
X(e, t, r, O(R({}, o), { type: "Point" }));
|
|
422
428
|
}
|
|
423
429
|
function ee(e, t, r) {
|
|
@@ -438,29 +444,29 @@ function te(e, t) {
|
|
|
438
444
|
const r = (t.extend[0] + t.extend[2]) / 2, o = (t.extend[1] + t.extend[3]) / 2;
|
|
439
445
|
return ee(e, [r, o], t);
|
|
440
446
|
}
|
|
441
|
-
function
|
|
447
|
+
function tt(e, t, r) {
|
|
442
448
|
const o = t.getGeometry().getExtent();
|
|
443
449
|
return te(e, O(R({}, r), { extend: o }));
|
|
444
450
|
}
|
|
445
|
-
function
|
|
451
|
+
function rt(e) {
|
|
446
452
|
return e.getView().getProjection();
|
|
447
453
|
}
|
|
448
454
|
function re(e) {
|
|
449
455
|
return e.getView().getZoom();
|
|
450
456
|
}
|
|
451
|
-
function
|
|
457
|
+
function nt(e, t) {
|
|
452
458
|
e.getView().setZoom(t);
|
|
453
459
|
}
|
|
454
|
-
function
|
|
460
|
+
function ot(e, t) {
|
|
455
461
|
e.un("click", () => {
|
|
456
462
|
}), e.un("pointermove", () => {
|
|
457
|
-
}),
|
|
463
|
+
}), Ye(t);
|
|
458
464
|
}
|
|
459
465
|
let F = null;
|
|
460
|
-
function
|
|
466
|
+
function st(e, t = {}) {
|
|
461
467
|
const r = new I();
|
|
462
|
-
F = new
|
|
463
|
-
condition:
|
|
468
|
+
F = new Ee({
|
|
469
|
+
condition: ve,
|
|
464
470
|
multi: t.multi || !1,
|
|
465
471
|
style: (c) => {
|
|
466
472
|
if (typeof t.getStyle == "function") {
|
|
@@ -476,7 +482,7 @@ function ot(e, t = {}) {
|
|
|
476
482
|
const o = F.getFeatures(), n = (c) => T(null, null, function* () {
|
|
477
483
|
const i = (t.layers || e.getLayers().getArray()).filter((w) => {
|
|
478
484
|
const h = w.getSource();
|
|
479
|
-
return w.getVisible() && (h instanceof
|
|
485
|
+
return w.getVisible() && (h instanceof N || h instanceof W);
|
|
480
486
|
});
|
|
481
487
|
if (i.length === 0) return;
|
|
482
488
|
const l = e.getView(), m = i.map((w) => T(null, null, function* () {
|
|
@@ -533,9 +539,9 @@ function ot(e, t = {}) {
|
|
|
533
539
|
}
|
|
534
540
|
};
|
|
535
541
|
}
|
|
536
|
-
function
|
|
542
|
+
function at(e, t = {}) {
|
|
537
543
|
var x;
|
|
538
|
-
const r = new I(), o = (x = t.debounceTime) != null ? x : 200, n = new
|
|
544
|
+
const r = new I(), o = (x = t.debounceTime) != null ? x : 200, n = new M(), s = new E({
|
|
539
545
|
source: n,
|
|
540
546
|
map: e,
|
|
541
547
|
style: t.style,
|
|
@@ -569,7 +575,7 @@ function st(e, t = {}) {
|
|
|
569
575
|
a && (a = null, n.clear(), e.getTargetElement().style.cursor = "", i.forEach((d) => d(null))), c && clearTimeout(c);
|
|
570
576
|
const b = (t.layers || e.getLayers().getArray()).filter((d) => {
|
|
571
577
|
const y = d.getSource();
|
|
572
|
-
return d.getVisible() && (y instanceof
|
|
578
|
+
return d.getVisible() && (y instanceof N || y instanceof W);
|
|
573
579
|
});
|
|
574
580
|
b.length !== 0 && (c = setTimeout(() => T(null, null, function* () {
|
|
575
581
|
const d = e.getView();
|
|
@@ -601,46 +607,46 @@ function st(e, t = {}) {
|
|
|
601
607
|
}
|
|
602
608
|
};
|
|
603
609
|
}
|
|
604
|
-
const
|
|
605
|
-
const r =
|
|
606
|
-
|
|
610
|
+
const St = (e, t) => {
|
|
611
|
+
const r = Ke(e, t);
|
|
612
|
+
Ge(r, t.baseLayers);
|
|
607
613
|
const o = {
|
|
608
614
|
targetId: e,
|
|
609
615
|
instance: r,
|
|
610
616
|
// 暴露原始实例以备不时之需
|
|
611
|
-
addMarker: (n, s, a) =>
|
|
617
|
+
addMarker: (n, s, a) => et(r, n, s, a),
|
|
612
618
|
createLayer: (n, s, a) => X(r, n, s, a),
|
|
613
|
-
createBlankLayer: (n, s) =>
|
|
614
|
-
visibleLayer: (n, s) =>
|
|
615
|
-
removeLayer: (n) =>
|
|
619
|
+
createBlankLayer: (n, s) => Je(r, n, s),
|
|
620
|
+
visibleLayer: (n, s) => Qe(r, n, s),
|
|
621
|
+
removeLayer: (n) => qe(r, n),
|
|
616
622
|
getLonLat: (n) => p(n),
|
|
617
623
|
getLayerByName: (n) => Z(r, n),
|
|
618
624
|
getSourceByName: (n) => Q(r, n),
|
|
619
|
-
useSelect: (n) =>
|
|
620
|
-
useHover: (n) =>
|
|
621
|
-
queryFeature: (n, s) =>
|
|
625
|
+
useSelect: (n) => st(r, n),
|
|
626
|
+
useHover: (n) => at(r, n),
|
|
627
|
+
queryFeature: (n, s) => Oe(r, n, s),
|
|
622
628
|
lightFeature: (n, s, a, c) => J(n, s, a, c),
|
|
623
|
-
flashFeature: (n, s, a) =>
|
|
629
|
+
flashFeature: (n, s, a) => Re(n, s, a),
|
|
624
630
|
flyTo: (n, s) => ee(r, n, s),
|
|
625
631
|
flyToByExtent: (n) => te(r, n),
|
|
626
|
-
flyToByFeature: (n, s) =>
|
|
627
|
-
getProjection: () =>
|
|
632
|
+
flyToByFeature: (n, s) => tt(r, n, s),
|
|
633
|
+
getProjection: () => rt(r),
|
|
628
634
|
getZoom: () => re(r),
|
|
629
|
-
setZoom: (n) =>
|
|
635
|
+
setZoom: (n) => nt(r, n),
|
|
630
636
|
getMapContext: (n) => Y(n),
|
|
631
637
|
onMapReady: (n, s) => K(n, s),
|
|
632
|
-
destroyMap: () =>
|
|
638
|
+
destroyMap: () => ot(r, e)
|
|
633
639
|
};
|
|
634
|
-
return
|
|
640
|
+
return Xe(e, o), o;
|
|
635
641
|
};
|
|
636
|
-
function
|
|
642
|
+
function xt(e, t) {
|
|
637
643
|
K(e, t);
|
|
638
644
|
}
|
|
639
|
-
function
|
|
645
|
+
function Pt(e) {
|
|
640
646
|
return Y(e);
|
|
641
647
|
}
|
|
642
648
|
export {
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
649
|
+
Pt as getMapContext,
|
|
650
|
+
xt as onMapReady,
|
|
651
|
+
St as useMap
|
|
646
652
|
};
|
package/dist/2d/types.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { Layer } from 'ol/layer';
|
|
|
4
4
|
import { FeatureLike } from 'ol/Feature';
|
|
5
5
|
import { HoverOptions, SelectOptions, UseHoverResult, UseSelectResult } from './interaction';
|
|
6
6
|
import { Source } from 'ol/source';
|
|
7
|
+
import { Projection } from 'ol/proj';
|
|
7
8
|
export interface BaseLayerOptions {
|
|
8
9
|
token?: string;
|
|
9
10
|
maxZoom?: number;
|
|
@@ -77,13 +78,13 @@ export interface MapContext {
|
|
|
77
78
|
queryFeature: (layerName: string, properties: any) => FeatureLike;
|
|
78
79
|
useSelect: (options: SelectOptions) => UseSelectResult;
|
|
79
80
|
useHover: (options: HoverOptions) => UseHoverResult;
|
|
80
|
-
flyTo: (coordinate: [number, number], options: flyOptions) =>
|
|
81
|
-
flyToByExtent: (options: flyOptions) =>
|
|
82
|
-
flyToByFeature: (feature: Feature, options: flyOptions) =>
|
|
83
|
-
getProjection: () =>
|
|
81
|
+
flyTo: (coordinate: [number, number], options: flyOptions) => Promise<boolean>;
|
|
82
|
+
flyToByExtent: (options: flyOptions) => Promise<boolean>;
|
|
83
|
+
flyToByFeature: (feature: Feature, options: flyOptions) => Promise<boolean>;
|
|
84
|
+
getProjection: () => Projection;
|
|
84
85
|
getZoom: () => number;
|
|
85
86
|
setZoom: (zoom: number) => void;
|
|
86
87
|
getMapContext: (id: string) => Promise<MapContext>;
|
|
87
|
-
onMapReady: (id: string, callback: () => void) => void;
|
|
88
|
-
destroyMap: (id: string) => void;
|
|
88
|
+
onMapReady: (id: string, callback: (ctx: MapContext) => void) => void;
|
|
89
|
+
destroyMap: (map: MapInstance, id: string) => void;
|
|
89
90
|
}
|
package/dist/2d/utils.d.ts
CHANGED
|
@@ -19,7 +19,10 @@ type dataType = {
|
|
|
19
19
|
* @param data 数据
|
|
20
20
|
* @returns [经度, 纬度]
|
|
21
21
|
*/
|
|
22
|
-
export declare function getLonLat(data: dataType
|
|
22
|
+
export declare function getLonLat(data: dataType, options?: {
|
|
23
|
+
lonLabel: string;
|
|
24
|
+
latLabel: string;
|
|
25
|
+
}): [number, number];
|
|
23
26
|
/**
|
|
24
27
|
* 根据图层名称删除图层
|
|
25
28
|
* @param map 地图实例
|
package/dist/3d/core.d.ts
CHANGED
|
@@ -1,19 +1,50 @@
|
|
|
1
|
+
import { Coordinates, flyOptions } from './types';
|
|
1
2
|
import * as Cesium from 'cesium';
|
|
2
3
|
/**
|
|
3
4
|
* 创建Viewer
|
|
4
5
|
*
|
|
5
|
-
* @param {String} [
|
|
6
|
+
* @param {String} [el] Cesium.viewer对应的DOM元素名:<div id="cesiumContainer"></div>
|
|
6
7
|
* @param {String} [terrainUrl] 地形链接
|
|
7
8
|
*/
|
|
8
|
-
export declare function
|
|
9
|
-
/**
|
|
10
|
-
* 初始化地图
|
|
11
|
-
* @param {Cesium.Viewer} viewer
|
|
12
|
-
*/
|
|
13
|
-
export declare function createBaseLayer(viewer: Cesium.Viewer, options: any): void;
|
|
9
|
+
export declare function createViewer(el: string, options?: any): Cesium.Viewer;
|
|
14
10
|
/**
|
|
15
11
|
* 添加标记
|
|
16
12
|
* @param {Cesium.Viewer} viewer
|
|
13
|
+
* @param {stringr} layerName
|
|
14
|
+
* @param points 数据
|
|
17
15
|
* @returns {void}
|
|
18
16
|
*/
|
|
19
|
-
export declare function addMarker(viewer: Cesium.Viewer, points: any[],
|
|
17
|
+
export declare function addMarker(viewer: Cesium.Viewer, layerName: string, points: any[], options: any): void;
|
|
18
|
+
/**
|
|
19
|
+
* 定位
|
|
20
|
+
* @param map 地图实例
|
|
21
|
+
* @param coordinate [经度, 纬度]
|
|
22
|
+
* @param options {flyOptions} 配置项
|
|
23
|
+
*/
|
|
24
|
+
export declare function flyTo(viewer: Cesium.Viewer, coordinate: Coordinates, options?: flyOptions): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* 飞行到初始位置
|
|
27
|
+
* @param viewer 视图对象
|
|
28
|
+
* @param duration 飞行时间
|
|
29
|
+
*/
|
|
30
|
+
export declare function flyHome(viewer: Cesium.Viewer, duration?: number): void;
|
|
31
|
+
/**
|
|
32
|
+
* 飞行到包围球
|
|
33
|
+
* @param viewer 视图对象
|
|
34
|
+
* @param boundingSphere
|
|
35
|
+
* @param options 配置项
|
|
36
|
+
*/
|
|
37
|
+
export declare function flyToBoundingSphere(viewer: Cesium.Viewer, boundingSphere: Cesium.BoundingSphere, options: flyOptions): Promise<boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* 设置视角
|
|
40
|
+
* @param viewer 视图对象
|
|
41
|
+
* @param coordinate [经度, 纬度, 高度]
|
|
42
|
+
* @param options 配置项
|
|
43
|
+
*/
|
|
44
|
+
export declare function setView(viewer: Cesium.Viewer, coordinate: Coordinates, options: flyOptions): void;
|
|
45
|
+
/**
|
|
46
|
+
* 销毁地图
|
|
47
|
+
* @param viewer 视图对象
|
|
48
|
+
* @param id 地图id
|
|
49
|
+
*/
|
|
50
|
+
export declare function destroyMap(viewer: Cesium.Viewer, id: string): void;
|
package/dist/3d/index.d.ts
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { MapContext } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 创建地图
|
|
4
|
+
* @param el 绑定地图元素Id
|
|
5
|
+
* @param options 配置项
|
|
6
|
+
* @returns 地图方法和地图实例
|
|
7
|
+
*/
|
|
8
|
+
export declare function useMap(el: string, options: any): MapContext;
|
|
9
|
+
/**
|
|
10
|
+
* 保证能获取到方法
|
|
11
|
+
* @param id
|
|
12
|
+
* @param callback
|
|
13
|
+
*/
|
|
14
|
+
export declare function onMapReady(id: string, callback: (ctx: MapContext) => void): void;
|
|
15
|
+
/**
|
|
16
|
+
* 获取地图返回的上下文
|
|
17
|
+
* @param id
|
|
18
|
+
* @returns Promise<MapContext>
|
|
19
|
+
*/
|
|
20
|
+
export declare function getMapContext(id: string): Promise<MapContext>;
|
package/dist/3d/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var M=Object.defineProperty,C=Object.defineProperties;var I=Object.getOwnPropertyDescriptors;var p=Object.getOwnPropertySymbols;var x=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var h=(t,r,e)=>r in t?M(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,u=(t,r)=>{for(var e in r||(r={}))x.call(r,e)&&h(t,e,r[e]);if(p)for(var e of p(r))O.call(r,e)&&h(t,e,r[e]);return t},f=(t,r)=>C(t,I(r));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("cesium"),b=require("../index.js");function k(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const a=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,a.get?a:{enumerable:!0,get:()=>t[e]})}}return r.default=t,Object.freeze(r)}const o=k(L);function _(t,r){const e={baseType:"img",noteType:"cia",token:"dadcbbdb5206b626a29ca739686b3087"},{baseType:a,noteType:n,token:i}=Object.assign(e,r),c="https://t{s}.tianditu.gov.cn",s=["0","1","2","3","4","5","6","7"],l=new o.UrlTemplateImageryProvider({url:`${c}/DataServer?T=${a}_w&x={x}&y={y}&l={z}&tk=${i}`,subdomains:s,tilingScheme:new o.WebMercatorTilingScheme});let d=t.imageryLayers.addImageryProvider(l);d.gamma=1;const T=new o.UrlTemplateImageryProvider({url:`${c}/DataServer?T=ibo_w&x={x}&y={y}&l={z}&tk=${i}`,subdomains:s,tilingScheme:new o.WebMercatorTilingScheme});t.imageryLayers.addImageryProvider(T);const v=new o.UrlTemplateImageryProvider({url:`${c}/DataServer?T=${n}_w&x={x}&y={y}&l={z}&tk=${i}`,subdomains:s,tilingScheme:new o.WebMercatorTilingScheme});t.imageryLayers.addImageryProvider(v)}function D(t,r){_(t,r)}function P(t,r,e,a){(!a||!a.type)&&(a=Object.assign({},e,a));const n=a.type||"Point";let i;switch(n){case"Point":i=B(t,r,e,a);break;case"LineString":i=R(t,r,e,a);break}return i}function B(t,r,e,a){const n=t.scene.primitives.add(new o.BillboardCollection);return n._layerName=r,e.forEach((i,c)=>{const s={scale:1,verticalOrigin:o.VerticalOrigin.BOTTOM,show:!0,disableDepthTestDistance:Number.POSITIVE_INFINITY,scaleByDistance:new o.NearFarScalar(1,1,1e5,.2)},l={position:o.Cartesian3.fromDegrees(...b.getLonLat(i),1),image:a.style||a.getStyle(i),id:i.id||`point_${c}`},d=n.add(u(u(u({},s),a),l));d._originStyle=f(u(u(u({},s),a),l),{color:o.Color.WHITE}),d.properties=i}),t.scene.requestRender(),n}function R(t,r,e,a){if(e.length<2)return;const n=E(e,a),i=new o.GroundPolylinePrimitive({geometryInstances:n,appearance:new o.PolylineColorAppearance({translucent:!0}),interleave:!0,allowPicking:!0,asynchronous:!1});i._layerName=r,t.scene.groundPrimitives.add(i)}function E(t,r){const e=[],a=t.map(c=>o.Cartesian3.fromDegrees(...b.getLonLat(c),0)),n=new o.GroundPolylineGeometry({positions:a,width:r.width||4,granularity:r.granularity||2e3}),i=new o.GeometryInstance({id:"pipeLine",geometry:n,attributes:{color:o.ColorGeometryInstanceAttribute.fromColor(o.Color.fromCssColorString(r.color))}});return e.push(i),e}function N(t,r){const e=t.scene.primitives,a=e.length;for(let n=0;n<a;n++){const i=e.get(n);if(i._layerName===r)return i}return null}const y=new Map,m={},g={},j=(t,r)=>{y.has(t)&&console.warn(`Map with target '${t}' already exists. Overwriting...`),y.set(t,r),m[t]&&(m[t].forEach(e=>e(r)),delete m[t]),g[t]&&(g[t].forEach(e=>e(r)),delete g[t])};function w(t){const r=y.get(t);return r?Promise.resolve(r):new Promise(e=>{g[t]=g[t]||[],g[t].push(e)})}const $=t=>{y.has(t)&&(y.delete(t),delete m[t])},S=(t,r)=>{const e=y.get(t);if(e){r(e);return}m[t]||(m[t]=[]),m[t].push(r)};function H(t,r={}){const e=new o.Viewer(t,{requestRenderMode:!0,maximumRenderTimeChange:1/0,selectionIndicator:!1,animation:!1,timeline:!1,geocoder:!1,homeButton:!1,baseLayerPicker:!1,sceneModePicker:!1,navigationHelpButton:!1,infoBox:!1,fullscreenButton:!1,shouldAnimate:!0,contextOptions:{webgl:{preserveDrawingBuffer:!0}}});let a;return o.defined(r.terrainUrl)?o.CesiumTerrainProvider.fromUrl(r.terrainUrl,{requestVertexNormals:!0,requestWaterMask:!0}).then(n=>{a=n,e.terrainProvider=a}):a=new o.EllipsoidTerrainProvider,e.terrainProvider=a,e._cesiumWidget._creditContainer.style.display="none",e.scene.globe.baseColor=new o.Color(0,0,0,0),e.scene.screenSpaceCameraController.minimumZoomDistance=r.minZoom||1,e.scene.screenSpaceCameraController.maximumZoomDistance=r.maxZoom||1e7,e.resolutionScale=window.devicePixelRatio>2?2:window.devicePixelRatio,e}function q(t,r,e,a){P(t,r,e,f(u({},a),{type:"Point"}))}function V(t,r,e){return new Promise((a,n)=>{t.camera.flyTo({destination:o.Cartesian3.fromDegrees(...r),duration:e.duration||1.2,orientation:{heading:e.heading||0,pitch:e.pitch||-Math.PI/2,roll:e.roll||0},easingFunction:e.easing||o.EasingFunction.LINEAR_NONE,maximumHeight:e.maxHeight||1e6,complete:()=>{a(!0)},cancel:()=>{a(!1)}})})}function G(t,r=1){return t.camera.flyHome(r)}function U(t,r,e){return new Promise((a,n)=>{t.camera.flyToBoundingSphere(r,{duration:e.duration||1e3,offset:new o.HeadingPitchRange(e.heading||0,e.pitch||-Math.PI/4,e.roll||0),easingFunction:e.easing,maximumHeight:e.maxHeight||1e6,complete:()=>{a(!0)},cancel:()=>{a(!1)}})})}function F(t,r,e){t.camera.setView({destination:o.Cartesian3.fromDegrees(...r),orientation:{heading:e.heading||0,pitch:e.pitch||-Math.PI/2,roll:e.roll||0}})}function W(t,r){t.destroy(),$(r)}function A(t,r){const e=new Set,a=new o.ScreenSpaceEventHandler(t.scene.canvas);let n=null;a.setInputAction(c=>{const s=t.scene.pick(c.position);if(n&&(Object.assign(n,n._originStyle),n=null,t.scene.requestRender()),o.defined(s)&&s.primitive instanceof o.Billboard){const l=s.primitive,d={billboard:l,properties:l.properties,event:c,pick:s};n=l,i(d),Object.assign(l,r.style||r.getStyle(l)),t.scene.requestRender()}},o.ScreenSpaceEventType.LEFT_CLICK);const i=c=>e.forEach(s=>s(c));return{onSelect:c=>(e.add(c),()=>e.delete(c)),clear(){e.clear()},destroy(){e.clear()}}}function z(t,r){const e=H(t,r);D(e,r);const a={targetId:t,instance:e,addMarker:(n,i,c)=>q(e,n,i,c),createLayer:(n,i,c)=>P(e,n,i,c),getLayerByName:n=>N(e,n),useSelect:n=>A(e,n),flyTo:(n,i)=>V(e,n,i),flyHome:n=>G(e,n),flyToBoundingSphere:(n,i)=>U(e,n,i),setView:(n,i)=>F(e,n,i),getMapContext:n=>w(n),onMapReady:(n,i)=>S(n,i),destroyMap:n=>W(e,n)};return j(t,a),a}function Z(t,r){S(t,r)}function K(t){return w(t)}exports.getMapContext=K;exports.onMapReady=Z;exports.useMap=z;
|