jgis 1.0.0

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.
@@ -0,0 +1,591 @@
1
+ var re = Object.defineProperty, ne = Object.defineProperties;
2
+ var oe = Object.getOwnPropertyDescriptors;
3
+ var Z = Object.getOwnPropertySymbols;
4
+ var se = Object.prototype.hasOwnProperty, ae = Object.prototype.propertyIsEnumerable;
5
+ var C = (e, t, r) => t in e ? re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, A = (e, t) => {
6
+ for (var r in t || (t = {}))
7
+ se.call(t, r) && C(e, r, t[r]);
8
+ if (Z)
9
+ for (var r of Z(t))
10
+ ae.call(t, r) && C(e, r, t[r]);
11
+ return e;
12
+ }, k = (e, t) => ne(e, oe(t));
13
+ var v = (e, t, r) => new Promise((n, o) => {
14
+ var s = (c) => {
15
+ try {
16
+ a(r.next(c));
17
+ } catch (u) {
18
+ o(u);
19
+ }
20
+ }, i = (c) => {
21
+ try {
22
+ a(r.throw(c));
23
+ } catch (u) {
24
+ o(u);
25
+ }
26
+ }, a = (c) => c.done ? n(c.value) : Promise.resolve(c.value).then(s, i);
27
+ a((r = r.apply(e, t)).next());
28
+ });
29
+ import { Map as ce, View as ie } from "ol";
30
+ import { Tile as O, Vector as F } from "ol/layer";
31
+ import { Vector as T, TileWMS as j, XYZ as V, ImageWMS as U } from "ol/source";
32
+ import { GeoJSON as p } from "ol/format";
33
+ import le from "ol/Overlay";
34
+ import { Polygon as ue, MultiPolygon as fe, MultiLineString as ye, LineString as ge, Point as me } from "ol/geom";
35
+ import de from "ol/Feature";
36
+ import "ol/extent";
37
+ import { Style as we, Circle as he, Fill as be } from "ol/style";
38
+ import { click as Me } from "ol/events/condition.js";
39
+ import Pe from "ol/interaction/Select";
40
+ var g = 63710088e-1, Ee = {
41
+ centimeters: g * 100,
42
+ centimetres: g * 100,
43
+ degrees: 360 / (2 * Math.PI),
44
+ feet: g * 3.28084,
45
+ inches: g * 39.37,
46
+ kilometers: g / 1e3,
47
+ kilometres: g / 1e3,
48
+ meters: g,
49
+ metres: g,
50
+ miles: g / 1609.344,
51
+ millimeters: g * 1e3,
52
+ millimetres: g * 1e3,
53
+ nauticalmiles: g / 1852,
54
+ radians: 1,
55
+ yards: g * 1.0936
56
+ };
57
+ function W(e, t, r = {}) {
58
+ const n = { type: "Feature" };
59
+ return (r.id === 0 || r.id) && (n.id = r.id), r.bbox && (n.bbox = r.bbox), n.properties = t || {}, n.geometry = e, n;
60
+ }
61
+ function $(e, t, r = {}) {
62
+ if (!e)
63
+ throw new Error("coordinates is required");
64
+ if (!Array.isArray(e))
65
+ throw new Error("coordinates must be an Array");
66
+ if (e.length < 2)
67
+ throw new Error("coordinates must be at least 2 numbers long");
68
+ if (!B(e[0]) || !B(e[1]))
69
+ throw new Error("coordinates must contain numbers");
70
+ return W({
71
+ type: "Point",
72
+ coordinates: e
73
+ }, t, r);
74
+ }
75
+ function Le(e, t, r = {}) {
76
+ for (const o of e) {
77
+ if (o.length < 4)
78
+ throw new Error(
79
+ "Each LinearRing of a Polygon must have 4 or more Positions."
80
+ );
81
+ if (o[o.length - 1].length !== o[0].length)
82
+ throw new Error("First and last Position are not equivalent.");
83
+ for (let s = 0; s < o[o.length - 1].length; s++)
84
+ if (o[o.length - 1][s] !== o[0][s])
85
+ throw new Error("First and last Position are not equivalent.");
86
+ }
87
+ return W({
88
+ type: "Polygon",
89
+ coordinates: e
90
+ }, t, r);
91
+ }
92
+ function Se(e, t = "kilometers") {
93
+ const r = Ee[t];
94
+ if (!r)
95
+ throw new Error(t + " units is invalid");
96
+ return e / r;
97
+ }
98
+ function G(e) {
99
+ return e % (2 * Math.PI) * 180 / Math.PI;
100
+ }
101
+ function R(e) {
102
+ return e % 360 * Math.PI / 180;
103
+ }
104
+ function B(e) {
105
+ return !isNaN(e) && e !== null && !Array.isArray(e);
106
+ }
107
+ function xe(e) {
108
+ if (!e)
109
+ throw new Error("coord is required");
110
+ if (!Array.isArray(e)) {
111
+ if (e.type === "Feature" && e.geometry !== null && e.geometry.type === "Point")
112
+ return [...e.geometry.coordinates];
113
+ if (e.type === "Point")
114
+ return [...e.coordinates];
115
+ }
116
+ if (Array.isArray(e) && e.length >= 2 && !Array.isArray(e[0]) && !Array.isArray(e[1]))
117
+ return [...e];
118
+ throw new Error("coord must be GeoJSON Point or an Array of numbers");
119
+ }
120
+ function ve(e, t, r, n = {}) {
121
+ const o = xe(e), s = R(o[0]), i = R(o[1]), a = R(r), c = Se(t, n.units), u = Math.asin(
122
+ Math.sin(i) * Math.cos(c) + Math.cos(i) * Math.sin(c) * Math.cos(a)
123
+ ), m = s + Math.atan2(
124
+ Math.sin(a) * Math.sin(c) * Math.cos(i),
125
+ Math.cos(c) - Math.sin(i) * Math.sin(u)
126
+ ), L = G(m), l = G(u);
127
+ return o[2] !== void 0 ? $([L, l, o[2]], n.properties) : $([L, l], n.properties);
128
+ }
129
+ function Fe(e, t, r = {}) {
130
+ const n = r.steps || 64, o = r.properties ? r.properties : !Array.isArray(e) && e.type === "Feature" && e.properties ? e.properties : {}, s = [];
131
+ for (let i = 0; i < n; i++)
132
+ s.push(
133
+ ve(e, t, i * -360 / n, r).geometry.coordinates
134
+ );
135
+ return s.push(s[0]), Le([s], o);
136
+ }
137
+ function D(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)] : [0, 0];
139
+ }
140
+ function q(e, t) {
141
+ e.getLayers().getArray().forEach((n) => {
142
+ n.get("name") == t && ("setSource" in n && n.setSource(null), "dispose" in n && n.dispose(), e.removeLayer(n));
143
+ });
144
+ }
145
+ function Te(e, t, r) {
146
+ const n = [];
147
+ let o;
148
+ const s = r.type || "Point";
149
+ t.forEach((a) => {
150
+ switch (s) {
151
+ case "Point":
152
+ o = Ie(a);
153
+ break;
154
+ case "LineString":
155
+ o = Ae(a);
156
+ break;
157
+ case "MultiLineString":
158
+ o = ke(a);
159
+ break;
160
+ case "MultiPolygon":
161
+ o = Re(a);
162
+ break;
163
+ case "Polygon":
164
+ o = Oe(a);
165
+ break;
166
+ }
167
+ if (!o) return;
168
+ const c = new de({
169
+ geometry: o,
170
+ data: a
171
+ });
172
+ c.set("layerName", e), n.push(c);
173
+ });
174
+ const i = new T();
175
+ return n.length > 0 && i.addFeatures(n), i;
176
+ }
177
+ function pe(e, t) {
178
+ return t.cqlFilter && (t.cqlFilter ? t.CQL_FILTER += ` and ${t.cqlFilter}` : t.CQL_FILTER = t.cqlFilter), new j({
179
+ url: t.url,
180
+ params: {
181
+ LAYERS: t.layers,
182
+ CQL_FILTER: t.CQL_FILTER
183
+ },
184
+ serverType: "geoserver",
185
+ crossOrigin: "anonymous"
186
+ });
187
+ }
188
+ function Ie(e) {
189
+ const t = D(e);
190
+ if (t)
191
+ return new me(t);
192
+ }
193
+ function Ae(e) {
194
+ return new ge(e.coordinates);
195
+ }
196
+ function ke(e) {
197
+ return new ye(e.coordinates);
198
+ }
199
+ function Re(e) {
200
+ return new fe(e.coordinates);
201
+ }
202
+ function Oe(e) {
203
+ return new ue(e.coordinates);
204
+ }
205
+ function z(e, t) {
206
+ let r = null;
207
+ return t.style ? r = t.style : t.getStyle ? r = (n, o) => t.getStyle(e, n, o) : r = je(), r;
208
+ }
209
+ function je() {
210
+ return (t, r) => new we({
211
+ image: new he({
212
+ radius: 5,
213
+ fill: new be({ color: "red" })
214
+ })
215
+ });
216
+ }
217
+ function ze(e, t = {}) {
218
+ const r = t.token || "dadcbbdb5206b626a29ca739686b3087", n = t.baseType || "img", o = t.noteType || "cia", s = new O({
219
+ className: "tdt-base-layer",
220
+ source: new V({
221
+ url: `http://t0.tianditu.com/DataServer?T=${n}_w&x={x}&y={y}&l={z}&tk=${r}`,
222
+ maxZoom: t.maxZoom || 18,
223
+ minZoom: t.minZoom || 2
224
+ }),
225
+ zIndex: t.zIndex || 1
226
+ });
227
+ s.set("name", "tdt-base-layer");
228
+ const i = new O({
229
+ className: "tdt-base-layer",
230
+ source: new V({
231
+ url: `http://t0.tianditu.com/DataServer?T=${o}_w&x={x}&y={y}&l={z}&tk=${r}`,
232
+ maxZoom: t.maxZoom || 18,
233
+ minZoom: t.minZoom || 2
234
+ }),
235
+ zIndex: t.zIndex ? t.zIndex + 1 : 2
236
+ });
237
+ return i.set("name", "tdt-baseNote-layer"), e.addLayer(s), e.addLayer(i), s;
238
+ }
239
+ function H(e, t, r, n) {
240
+ (!n || !n.type) && (n = Object.assign({}, r, n));
241
+ const o = n.type || "Point";
242
+ let s;
243
+ switch (o) {
244
+ case "GeoJSON":
245
+ s = Ne(t, r, e, n);
246
+ break;
247
+ case "Wms":
248
+ s = Ze(t, e, n);
249
+ break;
250
+ case "Point":
251
+ case "LineString":
252
+ case "MultiLineString":
253
+ case "Polygon":
254
+ case "MultiPolygon":
255
+ s = Ce(t, r, e, n);
256
+ break;
257
+ case "Circle":
258
+ s = Ve(t, r, e, n);
259
+ break;
260
+ case "Overlay":
261
+ s = $e(t, r, e, n);
262
+ break;
263
+ }
264
+ return s;
265
+ }
266
+ function _e(e, t) {
267
+ Array.isArray(t) ? t.forEach((r) => {
268
+ q(e, r);
269
+ }) : q(e, t);
270
+ }
271
+ function Ne(e, t, r, n) {
272
+ console.log(typeof t, t);
273
+ const o = new p().readFeatures(t, {
274
+ dataProjection: "EPSG:4326",
275
+ featureProjection: "EPSG:4326"
276
+ // 或 'EPSG:3857',看你的地图
277
+ }), s = new T();
278
+ s.addFeatures(o);
279
+ const i = new F({
280
+ source: s,
281
+ style: z(e, n),
282
+ zIndex: n.zIndex || 10
283
+ });
284
+ return i.set("name", e), i.set("type", "webgl"), r.addLayer(i), i;
285
+ }
286
+ function Ze(e, t, r) {
287
+ const n = new O({
288
+ opacity: r.opacity || 1,
289
+ source: pe(e, r),
290
+ zIndex: r.zIndex || 10
291
+ });
292
+ return n.set("name", e), t.addLayer(n), n;
293
+ }
294
+ function Ce(e, t, r, n) {
295
+ if (!t || t.length === 0) return null;
296
+ const o = new F({
297
+ source: Te(e, t, n),
298
+ style: z(e, n),
299
+ zIndex: n.zIndex || 10
300
+ });
301
+ return o.set("name", e), o.set("type", "webgl"), r.addLayer(o), o;
302
+ }
303
+ function Ve(e, t, r, n) {
304
+ const o = D(t), s = Fe(o, n.radius, { steps: 300, units: "meters" }), i = new p().readFeature(s, {
305
+ dataProjection: "EPSG:4326",
306
+ featureProjection: "EPSG:4490"
307
+ }), a = new T({ wrapX: !1 });
308
+ a.addFeature(i);
309
+ const c = new F({
310
+ source: a,
311
+ style: z(e, n),
312
+ zIndex: n.zIndex ? n.zIndex : 10
313
+ });
314
+ return c.set("name", e), c.set("type", "webgl"), r.addLayer(c), c;
315
+ }
316
+ function $e(e, t, r, n) {
317
+ const o = document.createElement("div"), s = new le({
318
+ element: o,
319
+ stopEvent: !1,
320
+ positioning: n.positioning || "bottom-center"
321
+ });
322
+ return s.set("name", e), s.set("type", "webgl"), r.addOverlay(s), { overlayer: s, content: o };
323
+ }
324
+ const x = /* @__PURE__ */ new Map(), E = {}, S = {}, Ge = (e, t) => {
325
+ x.has(e) && console.warn(`Map with target '${e}' already exists. Overwriting...`), x.set(e, t), E[e] && (E[e].forEach((r) => r(t)), delete E[e]), S[e] && (S[e].forEach((r) => r(t)), delete S[e]);
326
+ };
327
+ function J(e) {
328
+ const t = x.get(e);
329
+ return t ? Promise.resolve(t) : (console.warn(`Map '${e}' not found. Make sure useMap() is called first.`), new Promise((r) => {
330
+ S[e] = S[e] || [], S[e].push(r);
331
+ }));
332
+ }
333
+ const Be = (e) => {
334
+ x.has(e) && (x.delete(e), delete E[e]);
335
+ }, Q = (e, t) => {
336
+ const r = x.get(e);
337
+ if (r) {
338
+ t(r);
339
+ return;
340
+ }
341
+ E[e] || (E[e] = []), E[e].push(t);
342
+ };
343
+ function qe(e, t = {}) {
344
+ if (!e && !e.target)
345
+ throw new Error("请传入地图容器");
346
+ arguments.length === 1 && typeof e == "object" && (t = e, e = t.target);
347
+ const n = Object.assign({
348
+ zoom: 10,
349
+ center: [104.064839, 30.548857],
350
+ minZoom: 2,
351
+ maxZoom: 19,
352
+ projection: "EPSG:4326"
353
+ }, t), o = new ce({
354
+ //地图容器div的ID
355
+ target: e,
356
+ //地图容器中加载的图层
357
+ layers: [],
358
+ //地图视图设置
359
+ view: new ie({
360
+ projection: n.projection,
361
+ // 坐标系,有EPSG:4326和EPSG:3857
362
+ //地图初始中心点
363
+ center: n.center,
364
+ // 坐标
365
+ //地图初始显示级别
366
+ zoom: n.zoom,
367
+ minZoom: n.minZoom,
368
+ maxZoom: n.maxZoom
369
+ })
370
+ });
371
+ return o.targetId = e, o;
372
+ }
373
+ function Ue(e, t, r, n) {
374
+ H(e, t, r, k(A({}, n), { type: "Point" }));
375
+ }
376
+ function Y(e, t, r) {
377
+ return new Promise((n, o) => {
378
+ e.getView().animate(
379
+ {
380
+ center: t,
381
+ duration: r.duration || 1e3,
382
+ zoom: r.zoom || K(e),
383
+ rotation: r.rotation || 0,
384
+ easing: r.easing
385
+ },
386
+ n
387
+ );
388
+ });
389
+ }
390
+ function X(e, t) {
391
+ const r = (t.extend[0] + t.extend[2]) / 2, n = (t.extend[1] + t.extend[3]) / 2;
392
+ return Y(e, [r, n], t);
393
+ }
394
+ function We(e, t, r) {
395
+ const n = t.getGeometry().getExtent();
396
+ return X(e, k(A({}, r), { extend: n }));
397
+ }
398
+ function De(e) {
399
+ return e.getView().getProjection();
400
+ }
401
+ function K(e) {
402
+ return e.getView().getZoom();
403
+ }
404
+ function He(e, t) {
405
+ e.getView().setZoom(t);
406
+ }
407
+ function Je(e, t) {
408
+ e.un("click", () => {
409
+ }), e.un("pointermove", () => {
410
+ }), Be(t);
411
+ }
412
+ let P = null;
413
+ function Qe(e, t = {}) {
414
+ const r = new p();
415
+ P = new Pe({
416
+ condition: Me,
417
+ multi: t.multi || !1,
418
+ style: (a) => {
419
+ if (typeof t.getStyle == "function") {
420
+ const c = a.get("layerName");
421
+ return t.getStyle(c, a);
422
+ } else
423
+ return t.style;
424
+ },
425
+ // 高亮选中样式
426
+ // 过滤:只允许配置中的图层被选中 (仅对 Vector 有效)
427
+ layers: t.layers ? (a) => t.layers.includes(a) : void 0
428
+ }), e.addInteraction(P);
429
+ const n = P.getFeatures(), o = (a) => v(null, null, function* () {
430
+ const c = (t.layers || e.getLayers().getArray()).filter((w) => {
431
+ const h = w.getSource();
432
+ return w.getVisible() && (h instanceof j || h instanceof U);
433
+ });
434
+ if (c.length === 0) return;
435
+ const u = e.getView(), m = c.map((w) => v(null, null, function* () {
436
+ const f = w.getSource().getFeatureInfoUrl(a.coordinate, u.getResolution(), u.getProjection(), {
437
+ INFO_FORMAT: "application/json",
438
+ // 必须是 JSON 才能转 Feature
439
+ FEATURE_COUNT: 1
440
+ });
441
+ if (f)
442
+ try {
443
+ const b = yield (yield fetch(f)).json();
444
+ if (b.features && b.features.length > 0) {
445
+ const d = r.readFeatures(b);
446
+ return d.forEach((y) => {
447
+ y.set("wms_layer_source", w), y.set("wms_event_source", a), y.set("layerName", w.get("name"));
448
+ }), d;
449
+ }
450
+ } catch (M) {
451
+ console.warn(M);
452
+ }
453
+ return [];
454
+ })), l = (yield Promise.all(m)).flat();
455
+ l.length > 0 && (t.multi, n.extend(l), P.dispatchEvent({
456
+ type: "select",
457
+ selected: l,
458
+ deselected: [],
459
+ mapBrowserEvent: a
460
+ }));
461
+ });
462
+ e.on("singleclick", o);
463
+ const s = /* @__PURE__ */ new Set();
464
+ P.on("select", (a) => {
465
+ const c = n.getArray();
466
+ if (c.length > 0) {
467
+ const u = c.map((m) => ({
468
+ feature: m,
469
+ properties: m.getProperties(),
470
+ // 如果是 WMS 注入的,我们在上面 set 过了;如果是 Vector,用 native 方法获取
471
+ layer: m.get("wms_layer_source") || P.getLayer(m),
472
+ event: m.get("wms_event_source") || a
473
+ }));
474
+ i(u);
475
+ } else
476
+ i(null);
477
+ });
478
+ const i = (a) => s.forEach((c) => c(a));
479
+ return {
480
+ onSelect: (a) => (s.add(a), () => s.delete(a)),
481
+ clear: () => {
482
+ s.clear(), n.clear();
483
+ },
484
+ destroy: () => {
485
+ e.removeInteraction(P), e.un("singleclick", o), s.clear();
486
+ }
487
+ };
488
+ }
489
+ function Ye(e, t = {}) {
490
+ var L;
491
+ const r = new p(), n = (L = t.debounceTime) != null ? L : 200, o = new T(), s = new F({
492
+ source: o,
493
+ map: e,
494
+ style: t.style,
495
+ // 直接透传用户的样式配置
496
+ zIndex: 1e4,
497
+ // 保证在最上层
498
+ properties: { title: "JG_HOVER_LAYER" }
499
+ // 标记一下,防止自己拾取自己
500
+ });
501
+ let i = null, a = null;
502
+ const c = /* @__PURE__ */ new Set(), u = (l, w, h) => {
503
+ const f = l[0];
504
+ if (i !== f)
505
+ if (i = f, o.clear(), f ? (o.addFeature(f), t.cursor !== !1 && (e.getTargetElement().style.cursor = "pointer")) : t.cursor !== !1 && (e.getTargetElement().style.cursor = ""), f) {
506
+ const M = {
507
+ feature: f,
508
+ layer: w,
509
+ properties: f.getProperties(),
510
+ coordinate: h
511
+ };
512
+ c.forEach((b) => b([M]));
513
+ } else
514
+ c.forEach((M) => M(null));
515
+ }, m = (l) => {
516
+ if (l.dragging) return;
517
+ const w = l.pixel, h = l.coordinate;
518
+ let f = !1;
519
+ if (e.forEachFeatureAtPixel(w, (d, y) => {
520
+ f || y !== s && (t.layers && !t.layers.includes(y) || (f = !0, a && clearTimeout(a), u([d], y, h)));
521
+ }), f) return;
522
+ i && (i = null, o.clear(), e.getTargetElement().style.cursor = "", c.forEach((d) => d(null))), a && clearTimeout(a);
523
+ const b = (t.layers || e.getLayers().getArray()).filter((d) => {
524
+ const y = d.getSource();
525
+ return d.getVisible() && (y instanceof j || y instanceof U);
526
+ });
527
+ b.length !== 0 && (a = setTimeout(() => v(null, null, function* () {
528
+ const d = e.getView();
529
+ for (const y of b) {
530
+ const _ = y.getSource().getFeatureInfoUrl(h, d.getResolution(), d.getProjection(), {
531
+ INFO_FORMAT: "application/json",
532
+ FEATURE_COUNT: 1
533
+ });
534
+ if (_)
535
+ try {
536
+ const I = yield (yield fetch(_)).json();
537
+ if (I.features && I.features.length > 0) {
538
+ const N = r.readFeatures(I);
539
+ N.forEach((te) => te.set("wms_layer_source", y)), u(N, y, h);
540
+ return;
541
+ }
542
+ } catch (ee) {
543
+ }
544
+ }
545
+ }), n));
546
+ };
547
+ return e.on("pointermove", m), {
548
+ onHover: (l) => (c.add(l), () => c.delete(l)),
549
+ clear: () => {
550
+ o.clear(), i = null;
551
+ },
552
+ destroy: () => {
553
+ e.un("pointermove", m), e.removeLayer(s), c.clear(), a && clearTimeout(a);
554
+ }
555
+ };
556
+ }
557
+ const ft = (e, t) => {
558
+ const r = qe(e, t);
559
+ ze(r, t.baseLayers);
560
+ const n = {
561
+ targetId: e,
562
+ instance: r,
563
+ // 暴露原始实例以备不时之需
564
+ addMarker: (o, s, i) => Ue(r, o, s, i),
565
+ createLayer: (o, s, i) => H(r, o, s, i),
566
+ removeLayer: (o) => _e(r, o),
567
+ useSelect: (o) => Qe(r, o),
568
+ useHover: (o) => Ye(r, o),
569
+ flyTo: (o, s) => Y(r, o, s),
570
+ flyToByExtent: (o) => X(r, o),
571
+ flyToByFeature: (o, s) => We(r, o, s),
572
+ getProjection: () => De(r),
573
+ getZoom: () => K(r),
574
+ setZoom: (o) => He(r, o),
575
+ getMapContext: (o) => J(o),
576
+ onMapReady: (o, s) => Q(o, s),
577
+ destroyMap: () => Je(r, e)
578
+ };
579
+ return Ge(e, n), n;
580
+ };
581
+ function yt(e, t) {
582
+ Q(e, t);
583
+ }
584
+ function gt(e) {
585
+ return J(e);
586
+ }
587
+ export {
588
+ gt as getMapContext,
589
+ yt as onMapReady,
590
+ ft as useMap
591
+ };
@@ -0,0 +1,23 @@
1
+ import { Map } from 'ol';
2
+ import { JGisInstance, JGisConfig, JGisInitOptions } from './types';
3
+ export default class JGis implements JGisInstance {
4
+ protected Map: Map;
5
+ protected config: JGisConfig;
6
+ constructor(map: Map, options: JGisConfig);
7
+ init(options: JGisInitOptions): void;
8
+ /**
9
+ * 移动事件
10
+ * @param options
11
+ */
12
+ private moveEvent;
13
+ /**
14
+ * 点击事件
15
+ * @param options
16
+ */
17
+ private clickEvent;
18
+ private handleClick;
19
+ /**
20
+ * 清除选中要素
21
+ */
22
+ clearSelectFeature(): void;
23
+ }
@@ -0,0 +1,55 @@
1
+ import { Map } from 'ol';
2
+ import { default as Feature } from 'ol/Feature';
3
+ import { Layer } from 'ol/layer';
4
+ import { StyleLike } from 'ol/style/Style';
5
+ export interface SelectOptions {
6
+ /** 参与交互的图层 (包含 Vector 和 WMS) */
7
+ layers?: Layer<any, any>[];
8
+ /** 高亮样式 */
9
+ getStyle?: Function;
10
+ style?: StyleLike;
11
+ /** 是否支持多选 */
12
+ multi?: boolean;
13
+ }
14
+ export interface SelectResult {
15
+ feature: any;
16
+ properties: any;
17
+ layer: Layer<any, any> | null;
18
+ event: any;
19
+ }
20
+ export interface UseSelectResult {
21
+ onSelect: (result: (SelectResult: any) => void) => void;
22
+ clear: () => void;
23
+ destroy: () => void;
24
+ }
25
+ export interface UseHoverResult {
26
+ onHover: (result: (SelectResult: any) => void) => void;
27
+ clear: () => void;
28
+ destroy: () => void;
29
+ }
30
+ export declare function useSelect(map: Map, options?: SelectOptions): UseSelectResult;
31
+ export interface HoverOptions {
32
+ /** 监听图层 */
33
+ layers?: Layer<any, any>[];
34
+ /** 高亮样式 (支持 Style对象 或 函数) */
35
+ style?: StyleLike;
36
+ /**
37
+ * WMS 请求防抖时间 (毫秒)
38
+ * 鼠标停止移动多久后才去请求 WMS
39
+ * @default 200
40
+ */
41
+ debounceTime?: number;
42
+ /** 是否自动改变鼠标手势 (变为手型) */
43
+ cursor?: boolean;
44
+ }
45
+ export interface HoverEvent {
46
+ feature: Feature;
47
+ layer: Layer;
48
+ properties: any;
49
+ coordinate: [number, number];
50
+ }
51
+ export declare function useHover(map: Map, options?: HoverOptions): {
52
+ onHover: (cb: (res: HoverEvent[] | null) => void) => () => boolean;
53
+ clear: () => void;
54
+ destroy: () => void;
55
+ };