jgis 1.0.2 → 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 +164 -18
- package/dist/2d/index.d.ts +1 -1
- package/dist/2d/index.js +1 -1
- package/dist/2d/index.mjs +157 -151
- package/dist/2d/interaction.d.ts +2 -2
- package/dist/2d/types.d.ts +9 -8
- 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 +321 -78
- package/dist/3d/interaction.d.ts +47 -0
- package/dist/3d/layer.d.ts +71 -0
- package/dist/3d/store.d.ts +16 -0
- package/dist/3d/types.d.ts +68 -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 +7 -0
- package/package.json +70 -70
- package/dist/2d/index2.d.ts +0 -23
package/dist/2d/index.mjs
CHANGED
|
@@ -1,43 +1,44 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ae = Object.defineProperty, se = Object.defineProperties;
|
|
2
2
|
var ce = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var B = Object.getOwnPropertySymbols;
|
|
4
4
|
var ie = Object.prototype.hasOwnProperty, le = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var V = (e, t, r) => t in e ?
|
|
5
|
+
var V = (e, t, r) => t in e ? ae(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, R = (e, t) => {
|
|
6
6
|
for (var r in t || (t = {}))
|
|
7
7
|
ie.call(t, r) && V(e, r, t[r]);
|
|
8
8
|
if (B)
|
|
9
9
|
for (var r of B(t))
|
|
10
10
|
le.call(t, r) && V(e, r, t[r]);
|
|
11
11
|
return e;
|
|
12
|
-
}, O = (e, t) =>
|
|
12
|
+
}, O = (e, t) => se(e, ce(t));
|
|
13
13
|
var T = (e, t, r) => new Promise((o, n) => {
|
|
14
|
-
var
|
|
14
|
+
var a = (i) => {
|
|
15
15
|
try {
|
|
16
16
|
c(r.next(i));
|
|
17
17
|
} catch (l) {
|
|
18
18
|
n(l);
|
|
19
19
|
}
|
|
20
|
-
},
|
|
20
|
+
}, s = (i) => {
|
|
21
21
|
try {
|
|
22
22
|
c(r.throw(i));
|
|
23
23
|
} catch (l) {
|
|
24
24
|
n(l);
|
|
25
25
|
}
|
|
26
|
-
}, c = (i) => i.done ? o(i.value) : Promise.resolve(i.value).then(
|
|
26
|
+
}, c = (i) => i.done ? o(i.value) : Promise.resolve(i.value).then(a, s);
|
|
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(
|
|
@@ -80,8 +81,8 @@ function ve(e, t, r = {}) {
|
|
|
80
81
|
);
|
|
81
82
|
if (n[n.length - 1].length !== n[0].length)
|
|
82
83
|
throw new Error("First and last Position are not equivalent.");
|
|
83
|
-
for (let
|
|
84
|
-
if (n[n.length - 1][
|
|
84
|
+
for (let a = 0; a < n[n.length - 1].length; a++)
|
|
85
|
+
if (n[n.length - 1][a] !== n[0][a])
|
|
85
86
|
throw new Error("First and last Position are not equivalent.");
|
|
86
87
|
}
|
|
87
88
|
return H({
|
|
@@ -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,25 +118,25 @@ 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 =
|
|
122
|
-
Math.sin(
|
|
123
|
-
), m =
|
|
124
|
-
Math.sin(c) * Math.sin(i) * Math.cos(
|
|
125
|
-
Math.cos(i) - Math.sin(
|
|
121
|
+
function Ae(e, t, r, o = {}) {
|
|
122
|
+
const n = pe(e), a = z(n[0]), s = z(n[1]), c = z(r), i = Ie(t, o.units), l = Math.asin(
|
|
123
|
+
Math.sin(s) * Math.cos(i) + Math.cos(s) * Math.sin(i) * Math.cos(c)
|
|
124
|
+
), m = a + Math.atan2(
|
|
125
|
+
Math.sin(c) * Math.sin(i) * Math.cos(s),
|
|
126
|
+
Math.cos(i) - Math.sin(s) * Math.sin(l)
|
|
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
|
-
const o = r.steps || 64, n = r.properties ? r.properties : !Array.isArray(e) && e.type === "Feature" && e.properties ? e.properties : {},
|
|
131
|
-
for (let
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
function ke(e, t, r = {}) {
|
|
131
|
+
const o = r.steps || 64, n = r.properties ? r.properties : !Array.isArray(e) && e.type === "Feature" && e.properties ? e.properties : {}, a = [];
|
|
132
|
+
for (let s = 0; s < o; s++)
|
|
133
|
+
a.push(
|
|
134
|
+
Ae(e, t, s * -360 / o, r).geometry.coordinates
|
|
134
135
|
);
|
|
135
|
-
return
|
|
136
|
+
return a.push(a[0]), Te([a], 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) => {
|
|
@@ -143,53 +144,53 @@ function U(e, t) {
|
|
|
143
144
|
});
|
|
144
145
|
}
|
|
145
146
|
function J(e, t, r, o = !1) {
|
|
146
|
-
const n = o ? r.style || r.getStyle(e, t) : void 0,
|
|
147
|
-
n && typeof n.setZIndex == "function" && n.setZIndex(
|
|
147
|
+
const n = o ? r.style || r.getStyle(e, t) : void 0, a = o ? 999 : -1;
|
|
148
|
+
n && typeof n.setZIndex == "function" && n.setZIndex(a), 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
|
-
let n = Date.now(),
|
|
153
|
+
let n = Date.now(), a = !1, s = 0;
|
|
153
154
|
t.running = !0;
|
|
154
155
|
function c() {
|
|
155
156
|
if (!t.running) return;
|
|
156
157
|
const i = Date.now();
|
|
157
|
-
i - n >= o && (
|
|
158
|
+
i - n >= o && (a = !a, n = i, J(e, t, r, a), t.changed()), s = requestAnimationFrame(c);
|
|
158
159
|
}
|
|
159
160
|
c(), t.clearFlash = () => {
|
|
160
|
-
t.running = !1, cancelAnimationFrame(
|
|
161
|
+
t.running = !1, cancelAnimationFrame(s), t.setStyle(void 0);
|
|
161
162
|
};
|
|
162
163
|
}
|
|
163
|
-
function
|
|
164
|
-
var
|
|
164
|
+
function Oe(e, t, r) {
|
|
165
|
+
var s, c;
|
|
165
166
|
if (!r) return;
|
|
166
167
|
let o = p(r);
|
|
167
|
-
const n = (c = (
|
|
168
|
+
const n = (c = (s = Q(e, t)) == null ? void 0 : s.getFeatures) == null ? void 0 : c.call(s);
|
|
168
169
|
return n ? n.find(function(i) {
|
|
169
170
|
const l = i.getGeometry();
|
|
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
|
-
const
|
|
177
|
+
const a = r.type || "Point";
|
|
177
178
|
t.forEach((c) => {
|
|
178
|
-
switch (
|
|
179
|
+
switch (a) {
|
|
179
180
|
case "Point":
|
|
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
|
|
203
|
-
return o.length > 0 &&
|
|
203
|
+
const s = new M();
|
|
204
|
+
return o.length > 0 && s.addFeatures(o), s;
|
|
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",
|
|
250
|
+
function Ge(e, t = {}) {
|
|
251
|
+
const r = t.token || "dadcbbdb5206b626a29ca739686b3087", o = t.baseType || "img", n = t.noteType || "cia", a = 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}`,
|
|
@@ -256,8 +257,8 @@ function Ve(e, t = {}) {
|
|
|
256
257
|
}),
|
|
257
258
|
zIndex: t.zIndex || 1
|
|
258
259
|
});
|
|
259
|
-
|
|
260
|
-
const
|
|
260
|
+
a.set("name", "tdt-base-layer");
|
|
261
|
+
const s = 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}`,
|
|
@@ -266,78 +267,78 @@ function Ve(e, t = {}) {
|
|
|
266
267
|
}),
|
|
267
268
|
zIndex: t.zIndex ? t.zIndex + 1 : 2
|
|
268
269
|
});
|
|
269
|
-
return
|
|
270
|
+
return s.set("name", "tdt-baseNote-layer"), e.addLayer(a), e.addLayer(s), a;
|
|
270
271
|
}
|
|
271
272
|
function X(e, t, r, o) {
|
|
272
273
|
(!o || !o.type) && (o = Object.assign({}, r, o));
|
|
273
274
|
const n = o.type || "Point";
|
|
274
|
-
let
|
|
275
|
+
let a;
|
|
275
276
|
switch (n) {
|
|
276
277
|
case "GeoJSON":
|
|
277
|
-
|
|
278
|
+
a = $e(t, r, e, o);
|
|
278
279
|
break;
|
|
279
280
|
case "Wms":
|
|
280
|
-
|
|
281
|
+
a = 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
|
-
|
|
288
|
+
a = Ue(t, r, e, o);
|
|
288
289
|
break;
|
|
289
290
|
case "Circle":
|
|
290
|
-
|
|
291
|
+
a = We(t, r, e, o);
|
|
291
292
|
break;
|
|
292
293
|
case "Overlay":
|
|
293
|
-
|
|
294
|
+
a = He(t, e, o);
|
|
294
295
|
break;
|
|
295
296
|
}
|
|
296
|
-
return
|
|
297
|
+
return a;
|
|
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
|
-
}),
|
|
310
|
-
|
|
311
|
-
const
|
|
312
|
-
source:
|
|
310
|
+
}), a = new M();
|
|
311
|
+
a.addFeatures(n);
|
|
312
|
+
const s = new E({
|
|
313
|
+
source: a,
|
|
313
314
|
style: A(e, o),
|
|
314
315
|
zIndex: o.zIndex || 10
|
|
315
316
|
});
|
|
316
|
-
return
|
|
317
|
+
return s.set("name", e), s.set("type", "webgl"), r.addLayer(s), s;
|
|
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),
|
|
336
|
+
function We(e, t, r, o) {
|
|
337
|
+
const n = p(t), a = ke(n, o.radius, { steps: 300, units: "meters" }), s = new I().readFeature(a, {
|
|
337
338
|
dataProjection: "EPSG:4326",
|
|
338
339
|
featureProjection: "EPSG:4490"
|
|
339
|
-
}), c = new
|
|
340
|
-
c.addFeature(
|
|
340
|
+
}), c = new M({ wrapX: !1 });
|
|
341
|
+
c.addFeature(s);
|
|
341
342
|
const i = new E({
|
|
342
343
|
source: c,
|
|
343
344
|
style: A(e, o),
|
|
@@ -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 at(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* () {
|
|
@@ -507,7 +513,7 @@ function ot(e, t = {}) {
|
|
|
507
513
|
}));
|
|
508
514
|
});
|
|
509
515
|
e.on("singleclick", n);
|
|
510
|
-
const
|
|
516
|
+
const a = /* @__PURE__ */ new Set();
|
|
511
517
|
F.on("select", (c) => {
|
|
512
518
|
const i = o.getArray();
|
|
513
519
|
if (i.length > 0) {
|
|
@@ -518,24 +524,24 @@ function ot(e, t = {}) {
|
|
|
518
524
|
layer: m.get("wms_layer_source") || F.getLayer(m),
|
|
519
525
|
event: m.get("wms_event_source") || c
|
|
520
526
|
}));
|
|
521
|
-
|
|
527
|
+
s(l);
|
|
522
528
|
} else
|
|
523
|
-
|
|
529
|
+
s(null);
|
|
524
530
|
});
|
|
525
|
-
const
|
|
531
|
+
const s = (c) => a.forEach((i) => i(c));
|
|
526
532
|
return {
|
|
527
|
-
onSelect: (c) => (
|
|
533
|
+
onSelect: (c) => (a.add(c), () => a.delete(c)),
|
|
528
534
|
clear: () => {
|
|
529
|
-
|
|
535
|
+
a.clear(), o.clear();
|
|
530
536
|
},
|
|
531
537
|
destroy: () => {
|
|
532
|
-
e.removeInteraction(F), e.un("singleclick", n),
|
|
538
|
+
e.removeInteraction(F), e.un("singleclick", n), a.clear();
|
|
533
539
|
}
|
|
534
540
|
};
|
|
535
541
|
}
|
|
536
542
|
function st(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(), a = new E({
|
|
539
545
|
source: n,
|
|
540
546
|
map: e,
|
|
541
547
|
style: t.style,
|
|
@@ -545,11 +551,11 @@ function st(e, t = {}) {
|
|
|
545
551
|
properties: { title: "JG_HOVER_LAYER" }
|
|
546
552
|
// 标记一下,防止自己拾取自己
|
|
547
553
|
});
|
|
548
|
-
let
|
|
554
|
+
let s = null, c = null;
|
|
549
555
|
const i = /* @__PURE__ */ new Set(), l = (u, w, h) => {
|
|
550
556
|
const f = u[0];
|
|
551
|
-
if (
|
|
552
|
-
if (
|
|
557
|
+
if (s !== f)
|
|
558
|
+
if (s = f, n.clear(), f ? (n.addFeature(f), t.cursor !== !1 && (e.getTargetElement().style.cursor = "pointer")) : t.cursor !== !1 && (e.getTargetElement().style.cursor = ""), f) {
|
|
553
559
|
const L = {
|
|
554
560
|
feature: f,
|
|
555
561
|
layer: w,
|
|
@@ -564,12 +570,12 @@ function st(e, t = {}) {
|
|
|
564
570
|
const w = u.pixel, h = u.coordinate;
|
|
565
571
|
let f = !1;
|
|
566
572
|
if (e.forEachFeatureAtPixel(w, (d, y) => {
|
|
567
|
-
f || y !==
|
|
573
|
+
f || y !== a && (t.layers && !t.layers.includes(y) || (f = !0, c && clearTimeout(c), l([d], y, h)));
|
|
568
574
|
}), f) return;
|
|
569
|
-
|
|
575
|
+
s && (s = 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();
|
|
@@ -594,53 +600,53 @@ function st(e, t = {}) {
|
|
|
594
600
|
return e.on("pointermove", m), {
|
|
595
601
|
onHover: (u) => (i.add(u), () => i.delete(u)),
|
|
596
602
|
clear: () => {
|
|
597
|
-
n.clear(),
|
|
603
|
+
n.clear(), s = null;
|
|
598
604
|
},
|
|
599
605
|
destroy: () => {
|
|
600
|
-
e.un("pointermove", m), e.removeLayer(
|
|
606
|
+
e.un("pointermove", m), e.removeLayer(a), i.clear(), c && clearTimeout(c);
|
|
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,
|
|
612
|
-
createLayer: (n,
|
|
613
|
-
createBlankLayer: (n,
|
|
614
|
-
visibleLayer: (n,
|
|
615
|
-
removeLayer: (n) =>
|
|
617
|
+
addMarker: (n, a, s) => et(r, n, a, s),
|
|
618
|
+
createLayer: (n, a, s) => X(r, n, a, s),
|
|
619
|
+
createBlankLayer: (n, a) => Je(r, n, a),
|
|
620
|
+
visibleLayer: (n, a) => Qe(r, n, a),
|
|
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
|
-
|
|
620
|
-
|
|
621
|
-
queryFeature: (n,
|
|
622
|
-
lightFeature: (n,
|
|
623
|
-
flashFeature: (n,
|
|
624
|
-
flyTo: (n,
|
|
625
|
+
createSelect: (n) => at(r, n),
|
|
626
|
+
createHover: (n) => st(r, n),
|
|
627
|
+
queryFeature: (n, a) => Oe(r, n, a),
|
|
628
|
+
lightFeature: (n, a, s, c) => J(n, a, s, c),
|
|
629
|
+
flashFeature: (n, a, s) => Re(n, a, s),
|
|
630
|
+
flyTo: (n, a) => ee(r, n, a),
|
|
625
631
|
flyToByExtent: (n) => te(r, n),
|
|
626
|
-
flyToByFeature: (n,
|
|
627
|
-
getProjection: () =>
|
|
632
|
+
flyToByFeature: (n, a) => tt(r, n, a),
|
|
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
|
-
onMapReady: (n,
|
|
632
|
-
destroyMap: () =>
|
|
637
|
+
onMapReady: (n, a) => K(n, a),
|
|
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/interaction.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface UseHoverResult {
|
|
|
27
27
|
clear: () => void;
|
|
28
28
|
destroy: () => void;
|
|
29
29
|
}
|
|
30
|
-
export declare function
|
|
30
|
+
export declare function createSelect(map: Map, options?: SelectOptions): UseSelectResult;
|
|
31
31
|
export interface HoverOptions {
|
|
32
32
|
/** 监听图层 */
|
|
33
33
|
layers?: Layer<any, any>[];
|
|
@@ -48,7 +48,7 @@ export interface HoverEvent {
|
|
|
48
48
|
properties: any;
|
|
49
49
|
coordinate: [number, number];
|
|
50
50
|
}
|
|
51
|
-
export declare function
|
|
51
|
+
export declare function createHover(map: Map, options?: HoverOptions): {
|
|
52
52
|
onHover: (cb: (res: HoverEvent[] | null) => void) => () => boolean;
|
|
53
53
|
clear: () => void;
|
|
54
54
|
destroy: () => void;
|