jgis 1.0.1 → 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 +347 -286
- package/dist/2d/layer.d.ts +21 -2
- package/dist/2d/types.d.ts +16 -6
- package/dist/2d/utils.d.ts +5 -2
- 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
|
@@ -1,43 +1,44 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var se = Object.defineProperty, ae = Object.defineProperties;
|
|
2
|
+
var ce = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var B = Object.getOwnPropertySymbols;
|
|
4
|
+
var ie = Object.prototype.hasOwnProperty, le = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var V = (e, t, r) => t in e ? se(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
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var r of
|
|
10
|
-
|
|
7
|
+
ie.call(t, r) && V(e, r, t[r]);
|
|
8
|
+
if (B)
|
|
9
|
+
for (var r of B(t))
|
|
10
|
+
le.call(t, r) && V(e, r, t[r]);
|
|
11
11
|
return e;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
var s = (
|
|
12
|
+
}, O = (e, t) => ae(e, ce(t));
|
|
13
|
+
var T = (e, t, r) => new Promise((o, n) => {
|
|
14
|
+
var s = (i) => {
|
|
15
15
|
try {
|
|
16
|
-
|
|
17
|
-
} catch (
|
|
18
|
-
|
|
16
|
+
c(r.next(i));
|
|
17
|
+
} catch (l) {
|
|
18
|
+
n(l);
|
|
19
19
|
}
|
|
20
|
-
},
|
|
20
|
+
}, a = (i) => {
|
|
21
21
|
try {
|
|
22
|
-
|
|
23
|
-
} catch (
|
|
24
|
-
|
|
22
|
+
c(r.throw(i));
|
|
23
|
+
} catch (l) {
|
|
24
|
+
n(l);
|
|
25
25
|
}
|
|
26
|
-
},
|
|
27
|
-
|
|
26
|
+
}, c = (i) => i.done ? o(i.value) : Promise.resolve(i.value).then(s, a);
|
|
27
|
+
c((r = r.apply(e, t)).next());
|
|
28
28
|
});
|
|
29
|
-
import { Map as
|
|
30
|
-
import { Tile as
|
|
31
|
-
import { Vector as
|
|
32
|
-
import { GeoJSON as
|
|
33
|
-
import
|
|
34
|
-
import { Polygon as
|
|
35
|
-
import
|
|
29
|
+
import { Map as ue, View as fe } from "ol";
|
|
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
|
+
import { GeoJSON as I } from "ol/format";
|
|
33
|
+
import ye from "ol/Overlay";
|
|
34
|
+
import { Geometry as ge, Polygon as me, MultiPolygon as de, MultiLineString as we, LineString as he, Point as be } from "ol/geom";
|
|
35
|
+
import Le from "ol/Feature";
|
|
36
36
|
import "ol/extent";
|
|
37
|
-
import { Style as
|
|
38
|
-
import {
|
|
39
|
-
import
|
|
40
|
-
|
|
37
|
+
import { Style as Fe, Circle as Se, Fill as xe } from "ol/style";
|
|
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),
|
|
@@ -54,57 +55,57 @@ var g = 63710088e-1, Ee = {
|
|
|
54
55
|
radians: 1,
|
|
55
56
|
yards: g * 1.0936
|
|
56
57
|
};
|
|
57
|
-
function
|
|
58
|
-
const
|
|
59
|
-
return (r.id === 0 || r.id) && (
|
|
58
|
+
function H(e, t, r = {}) {
|
|
59
|
+
const o = { type: "Feature" };
|
|
60
|
+
return (r.id === 0 || r.id) && (o.id = r.id), r.bbox && (o.bbox = r.bbox), o.properties = t || {}, o.geometry = e, o;
|
|
60
61
|
}
|
|
61
|
-
function
|
|
62
|
+
function q(e, t, r = {}) {
|
|
62
63
|
if (!e)
|
|
63
64
|
throw new Error("coordinates is required");
|
|
64
65
|
if (!Array.isArray(e))
|
|
65
66
|
throw new Error("coordinates must be an Array");
|
|
66
67
|
if (e.length < 2)
|
|
67
68
|
throw new Error("coordinates must be at least 2 numbers long");
|
|
68
|
-
if (!
|
|
69
|
+
if (!D(e[0]) || !D(e[1]))
|
|
69
70
|
throw new Error("coordinates must contain numbers");
|
|
70
|
-
return
|
|
71
|
+
return H({
|
|
71
72
|
type: "Point",
|
|
72
73
|
coordinates: e
|
|
73
74
|
}, t, r);
|
|
74
75
|
}
|
|
75
|
-
function
|
|
76
|
-
for (const
|
|
77
|
-
if (
|
|
76
|
+
function Te(e, t, r = {}) {
|
|
77
|
+
for (const n of e) {
|
|
78
|
+
if (n.length < 4)
|
|
78
79
|
throw new Error(
|
|
79
80
|
"Each LinearRing of a Polygon must have 4 or more Positions."
|
|
80
81
|
);
|
|
81
|
-
if (
|
|
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 s = 0; s <
|
|
84
|
-
if (
|
|
84
|
+
for (let s = 0; s < n[n.length - 1].length; s++)
|
|
85
|
+
if (n[n.length - 1][s] !== n[0][s])
|
|
85
86
|
throw new Error("First and last Position are not equivalent.");
|
|
86
87
|
}
|
|
87
|
-
return
|
|
88
|
+
return H({
|
|
88
89
|
type: "Polygon",
|
|
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;
|
|
97
98
|
}
|
|
98
|
-
function
|
|
99
|
+
function $(e) {
|
|
99
100
|
return e % (2 * Math.PI) * 180 / Math.PI;
|
|
100
101
|
}
|
|
101
|
-
function
|
|
102
|
+
function z(e) {
|
|
102
103
|
return e % 360 * Math.PI / 180;
|
|
103
104
|
}
|
|
104
|
-
function
|
|
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,65 +118,93 @@ function xe(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
|
|
122
|
-
Math.sin(
|
|
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(
|
|
123
|
+
Math.sin(a) * Math.cos(i) + Math.cos(a) * Math.sin(i) * Math.cos(c)
|
|
123
124
|
), m = s + Math.atan2(
|
|
124
|
-
Math.sin(
|
|
125
|
-
Math.cos(
|
|
126
|
-
),
|
|
127
|
-
return
|
|
128
|
-
}
|
|
129
|
-
function
|
|
130
|
-
const
|
|
131
|
-
for (let
|
|
125
|
+
Math.sin(c) * Math.sin(i) * Math.cos(a),
|
|
126
|
+
Math.cos(i) - Math.sin(a) * Math.sin(l)
|
|
127
|
+
), x = $(m), u = $(l);
|
|
128
|
+
return n[2] !== void 0 ? q([x, u, n[2]], o.properties) : q([x, u], o.properties);
|
|
129
|
+
}
|
|
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 : {}, s = [];
|
|
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
|
|
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
|
-
function
|
|
141
|
-
e.getLayers().getArray().forEach((
|
|
142
|
-
|
|
141
|
+
function U(e, t) {
|
|
142
|
+
e.getLayers().getArray().forEach((o) => {
|
|
143
|
+
o.get("name") == t && ("setSource" in o && o.setSource(null), "dispose" in o && o.dispose(), e.removeLayer(o));
|
|
143
144
|
});
|
|
144
145
|
}
|
|
145
|
-
function
|
|
146
|
-
const n =
|
|
147
|
-
|
|
146
|
+
function J(e, t, r, o = !1) {
|
|
147
|
+
const n = o ? r.style || r.getStyle(e, t) : void 0, s = o ? 999 : -1;
|
|
148
|
+
n && typeof n.setZIndex == "function" && n.setZIndex(s), t.setStyle(n);
|
|
149
|
+
}
|
|
150
|
+
function Re(e, t, r) {
|
|
151
|
+
if (!t) return;
|
|
152
|
+
const o = r.time || 300;
|
|
153
|
+
let n = Date.now(), s = !1, a = 0;
|
|
154
|
+
t.running = !0;
|
|
155
|
+
function c() {
|
|
156
|
+
if (!t.running) return;
|
|
157
|
+
const i = Date.now();
|
|
158
|
+
i - n >= o && (s = !s, n = i, J(e, t, r, s), t.changed()), a = requestAnimationFrame(c);
|
|
159
|
+
}
|
|
160
|
+
c(), t.clearFlash = () => {
|
|
161
|
+
t.running = !1, cancelAnimationFrame(a), t.setStyle(void 0);
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function Oe(e, t, r) {
|
|
165
|
+
var a, c;
|
|
166
|
+
if (!r) return;
|
|
167
|
+
let o = p(r);
|
|
168
|
+
const n = (c = (a = Q(e, t)) == null ? void 0 : a.getFeatures) == null ? void 0 : c.call(a);
|
|
169
|
+
return n ? n.find(function(i) {
|
|
170
|
+
const l = i.getGeometry();
|
|
171
|
+
return l && l instanceof ge && typeof l.intersectsCoordinate == "function" ? l.intersectsCoordinate(o) : !1;
|
|
172
|
+
}) : void 0;
|
|
173
|
+
}
|
|
174
|
+
function ze(e, t, r) {
|
|
175
|
+
const o = [];
|
|
176
|
+
let n;
|
|
148
177
|
const s = r.type || "Point";
|
|
149
|
-
t.forEach((
|
|
178
|
+
t.forEach((c) => {
|
|
150
179
|
switch (s) {
|
|
151
180
|
case "Point":
|
|
152
|
-
|
|
181
|
+
n = Ne(c);
|
|
153
182
|
break;
|
|
154
183
|
case "LineString":
|
|
155
|
-
|
|
184
|
+
n = Ze(c);
|
|
156
185
|
break;
|
|
157
186
|
case "MultiLineString":
|
|
158
|
-
|
|
187
|
+
n = _e(c);
|
|
159
188
|
break;
|
|
160
189
|
case "MultiPolygon":
|
|
161
|
-
|
|
190
|
+
n = Ce(c);
|
|
162
191
|
break;
|
|
163
192
|
case "Polygon":
|
|
164
|
-
|
|
193
|
+
n = Be(c);
|
|
165
194
|
break;
|
|
166
195
|
}
|
|
167
|
-
if (!
|
|
168
|
-
const
|
|
169
|
-
geometry:
|
|
170
|
-
data:
|
|
196
|
+
if (!n) return;
|
|
197
|
+
const i = new Le({
|
|
198
|
+
geometry: n,
|
|
199
|
+
data: c
|
|
171
200
|
});
|
|
172
|
-
|
|
201
|
+
i.set("layerName", e), o.push(i);
|
|
173
202
|
});
|
|
174
|
-
const
|
|
175
|
-
return
|
|
203
|
+
const a = new M();
|
|
204
|
+
return o.length > 0 && a.addFeatures(o), a;
|
|
176
205
|
}
|
|
177
|
-
function
|
|
178
|
-
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({
|
|
179
208
|
url: t.url,
|
|
180
209
|
params: {
|
|
181
210
|
LAYERS: t.layers,
|
|
@@ -185,255 +214,279 @@ function pe(e, t) {
|
|
|
185
214
|
crossOrigin: "anonymous"
|
|
186
215
|
});
|
|
187
216
|
}
|
|
188
|
-
function
|
|
189
|
-
const
|
|
217
|
+
function Q(e, t) {
|
|
218
|
+
const r = Z(e, t);
|
|
219
|
+
return r == null ? void 0 : r.getSource();
|
|
220
|
+
}
|
|
221
|
+
function Ne(e) {
|
|
222
|
+
const t = p(e);
|
|
190
223
|
if (t)
|
|
191
|
-
return new
|
|
224
|
+
return new be(t);
|
|
192
225
|
}
|
|
193
|
-
function
|
|
194
|
-
return new
|
|
226
|
+
function Ze(e) {
|
|
227
|
+
return new he(e.coordinates);
|
|
195
228
|
}
|
|
196
|
-
function
|
|
197
|
-
return new
|
|
229
|
+
function _e(e) {
|
|
230
|
+
return new we(e.coordinates);
|
|
198
231
|
}
|
|
199
|
-
function
|
|
200
|
-
return new
|
|
232
|
+
function Ce(e) {
|
|
233
|
+
return new de(e.coordinates);
|
|
201
234
|
}
|
|
202
|
-
function
|
|
203
|
-
return new
|
|
235
|
+
function Be(e) {
|
|
236
|
+
return new me(e.coordinates);
|
|
204
237
|
}
|
|
205
|
-
function
|
|
238
|
+
function A(e, t) {
|
|
206
239
|
let r = null;
|
|
207
|
-
return t.style ? r = t.style : t.getStyle ? r = (
|
|
240
|
+
return t.style ? r = t.style : t.getStyle ? r = (o, n) => t.getStyle(e, o, n) : r = Ve(), r;
|
|
208
241
|
}
|
|
209
|
-
function
|
|
210
|
-
return (t, r) => new
|
|
211
|
-
image: new
|
|
242
|
+
function Ve() {
|
|
243
|
+
return (t, r) => new Fe({
|
|
244
|
+
image: new Se({
|
|
212
245
|
radius: 5,
|
|
213
|
-
fill: new
|
|
246
|
+
fill: new xe({ color: "red" })
|
|
214
247
|
})
|
|
215
248
|
});
|
|
216
249
|
}
|
|
217
|
-
function
|
|
218
|
-
const r = t.token || "dadcbbdb5206b626a29ca739686b3087",
|
|
250
|
+
function Ge(e, t = {}) {
|
|
251
|
+
const r = t.token || "dadcbbdb5206b626a29ca739686b3087", o = t.baseType || "img", n = t.noteType || "cia", s = new j({
|
|
219
252
|
className: "tdt-base-layer",
|
|
220
|
-
source: new
|
|
221
|
-
url: `http://t0.tianditu.com/DataServer?T=${
|
|
253
|
+
source: new G({
|
|
254
|
+
url: `http://t0.tianditu.com/DataServer?T=${o}_w&x={x}&y={y}&l={z}&tk=${r}`,
|
|
222
255
|
maxZoom: t.maxZoom || 18,
|
|
223
256
|
minZoom: t.minZoom || 2
|
|
224
257
|
}),
|
|
225
258
|
zIndex: t.zIndex || 1
|
|
226
259
|
});
|
|
227
260
|
s.set("name", "tdt-base-layer");
|
|
228
|
-
const
|
|
261
|
+
const a = new j({
|
|
229
262
|
className: "tdt-base-layer",
|
|
230
|
-
source: new
|
|
231
|
-
url: `http://t0.tianditu.com/DataServer?T=${
|
|
263
|
+
source: new G({
|
|
264
|
+
url: `http://t0.tianditu.com/DataServer?T=${n}_w&x={x}&y={y}&l={z}&tk=${r}`,
|
|
232
265
|
maxZoom: t.maxZoom || 18,
|
|
233
266
|
minZoom: t.minZoom || 2
|
|
234
267
|
}),
|
|
235
268
|
zIndex: t.zIndex ? t.zIndex + 1 : 2
|
|
236
269
|
});
|
|
237
|
-
return
|
|
270
|
+
return a.set("name", "tdt-baseNote-layer"), e.addLayer(s), e.addLayer(a), s;
|
|
238
271
|
}
|
|
239
|
-
function
|
|
240
|
-
(!
|
|
241
|
-
const
|
|
272
|
+
function X(e, t, r, o) {
|
|
273
|
+
(!o || !o.type) && (o = Object.assign({}, r, o));
|
|
274
|
+
const n = o.type || "Point";
|
|
242
275
|
let s;
|
|
243
|
-
switch (
|
|
276
|
+
switch (n) {
|
|
244
277
|
case "GeoJSON":
|
|
245
|
-
s =
|
|
278
|
+
s = $e(t, r, e, o);
|
|
246
279
|
break;
|
|
247
280
|
case "Wms":
|
|
248
|
-
s =
|
|
281
|
+
s = De(t, e, o);
|
|
249
282
|
break;
|
|
250
283
|
case "Point":
|
|
251
284
|
case "LineString":
|
|
252
285
|
case "MultiLineString":
|
|
253
286
|
case "Polygon":
|
|
254
287
|
case "MultiPolygon":
|
|
255
|
-
s =
|
|
288
|
+
s = Ue(t, r, e, o);
|
|
256
289
|
break;
|
|
257
290
|
case "Circle":
|
|
258
|
-
s =
|
|
291
|
+
s = We(t, r, e, o);
|
|
259
292
|
break;
|
|
260
293
|
case "Overlay":
|
|
261
|
-
s =
|
|
294
|
+
s = He(t, e, o);
|
|
262
295
|
break;
|
|
263
296
|
}
|
|
264
297
|
return s;
|
|
265
298
|
}
|
|
266
|
-
function
|
|
299
|
+
function qe(e, t) {
|
|
267
300
|
Array.isArray(t) ? t.forEach((r) => {
|
|
268
|
-
|
|
269
|
-
}) :
|
|
301
|
+
U(e, r);
|
|
302
|
+
}) : U(e, t);
|
|
270
303
|
}
|
|
271
|
-
function
|
|
304
|
+
function $e(e, t, r, o) {
|
|
272
305
|
console.log(typeof t, t);
|
|
273
|
-
const
|
|
306
|
+
const n = new I().readFeatures(t, {
|
|
274
307
|
dataProjection: "EPSG:4326",
|
|
275
308
|
featureProjection: "EPSG:4326"
|
|
276
309
|
// 或 'EPSG:3857',看你的地图
|
|
277
|
-
}), s = new
|
|
278
|
-
s.addFeatures(
|
|
279
|
-
const
|
|
310
|
+
}), s = new M();
|
|
311
|
+
s.addFeatures(n);
|
|
312
|
+
const a = new E({
|
|
280
313
|
source: s,
|
|
281
|
-
style:
|
|
282
|
-
zIndex:
|
|
314
|
+
style: A(e, o),
|
|
315
|
+
zIndex: o.zIndex || 10
|
|
283
316
|
});
|
|
284
|
-
return
|
|
317
|
+
return a.set("name", e), a.set("type", "webgl"), r.addLayer(a), a;
|
|
285
318
|
}
|
|
286
|
-
function
|
|
287
|
-
const
|
|
319
|
+
function De(e, t, r) {
|
|
320
|
+
const o = new j({
|
|
288
321
|
opacity: r.opacity || 1,
|
|
289
|
-
source:
|
|
322
|
+
source: je(e, r),
|
|
290
323
|
zIndex: r.zIndex || 10
|
|
291
324
|
});
|
|
292
|
-
return
|
|
325
|
+
return o.set("name", e), t.addLayer(o), o;
|
|
293
326
|
}
|
|
294
|
-
function
|
|
327
|
+
function Ue(e, t, r, o) {
|
|
295
328
|
if (!t || t.length === 0) return null;
|
|
296
|
-
const
|
|
297
|
-
source:
|
|
298
|
-
style:
|
|
299
|
-
zIndex:
|
|
329
|
+
const n = new E({
|
|
330
|
+
source: ze(e, t, o),
|
|
331
|
+
style: A(e, o),
|
|
332
|
+
zIndex: o.zIndex || 10
|
|
300
333
|
});
|
|
301
|
-
return
|
|
334
|
+
return n.set("name", e), n.set("type", "webgl"), r.addLayer(n), n;
|
|
302
335
|
}
|
|
303
|
-
function
|
|
304
|
-
const
|
|
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, {
|
|
305
338
|
dataProjection: "EPSG:4326",
|
|
306
339
|
featureProjection: "EPSG:4490"
|
|
307
|
-
}),
|
|
308
|
-
|
|
309
|
-
const
|
|
310
|
-
source:
|
|
311
|
-
style:
|
|
312
|
-
zIndex:
|
|
340
|
+
}), c = new M({ wrapX: !1 });
|
|
341
|
+
c.addFeature(a);
|
|
342
|
+
const i = new E({
|
|
343
|
+
source: c,
|
|
344
|
+
style: A(e, o),
|
|
345
|
+
zIndex: o.zIndex ? o.zIndex : 10
|
|
313
346
|
});
|
|
314
|
-
return
|
|
347
|
+
return i.set("name", e), i.set("type", "webgl"), r.addLayer(i), i;
|
|
315
348
|
}
|
|
316
|
-
function
|
|
317
|
-
const o = document.createElement("div"),
|
|
349
|
+
function He(e, t, r) {
|
|
350
|
+
const o = document.createElement("div"), n = new ye({
|
|
318
351
|
element: o,
|
|
319
352
|
stopEvent: !1,
|
|
320
|
-
positioning:
|
|
353
|
+
positioning: r.positioning || "bottom-center"
|
|
321
354
|
});
|
|
322
|
-
return
|
|
355
|
+
return n.set("name", e), n.set("type", "webgl"), t.addOverlay(n), { overlayer: n, content: o };
|
|
356
|
+
}
|
|
357
|
+
function Je(e, t, r) {
|
|
358
|
+
const o = new E({
|
|
359
|
+
source: new M({ wrapX: !1 }),
|
|
360
|
+
zIndex: r.zIndex ? r.zIndex : 10,
|
|
361
|
+
style: A(t, r)
|
|
362
|
+
});
|
|
363
|
+
return o.set("name", t), o.set("type", "webgl"), e.addLayer(o), o;
|
|
364
|
+
}
|
|
365
|
+
function Z(e, t) {
|
|
366
|
+
return e.getAllLayers().find((n) => n.get("name") === t);
|
|
323
367
|
}
|
|
324
|
-
|
|
325
|
-
|
|
368
|
+
function Qe(e, t, r) {
|
|
369
|
+
const o = Z(e, t);
|
|
370
|
+
return o.setVisible(r), o;
|
|
371
|
+
}
|
|
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]);
|
|
326
374
|
};
|
|
327
|
-
function
|
|
328
|
-
const t =
|
|
329
|
-
return t ? Promise.resolve(t) :
|
|
330
|
-
|
|
331
|
-
})
|
|
332
|
-
}
|
|
333
|
-
const
|
|
334
|
-
|
|
335
|
-
},
|
|
336
|
-
const r =
|
|
375
|
+
function Y(e) {
|
|
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
|
+
});
|
|
380
|
+
}
|
|
381
|
+
const Ye = (e) => {
|
|
382
|
+
v.has(e) && (v.delete(e), delete S[e]);
|
|
383
|
+
}, K = (e, t) => {
|
|
384
|
+
const r = v.get(e);
|
|
337
385
|
if (r) {
|
|
338
386
|
t(r);
|
|
339
387
|
return;
|
|
340
388
|
}
|
|
341
|
-
|
|
389
|
+
S[e] || (S[e] = []), S[e].push(t);
|
|
342
390
|
};
|
|
343
|
-
function
|
|
391
|
+
function Ke(e, t = {}) {
|
|
344
392
|
if (!e && !e.target)
|
|
345
|
-
throw new Error("
|
|
393
|
+
throw new Error("is not a valid element");
|
|
346
394
|
arguments.length === 1 && typeof e == "object" && (t = e, e = t.target);
|
|
347
|
-
const
|
|
395
|
+
const o = Object.assign({
|
|
348
396
|
zoom: 10,
|
|
349
397
|
center: [104.064839, 30.548857],
|
|
350
398
|
minZoom: 2,
|
|
351
399
|
maxZoom: 19,
|
|
352
400
|
projection: "EPSG:4326"
|
|
353
|
-
}, t),
|
|
401
|
+
}, t), n = new ue({
|
|
354
402
|
//地图容器div的ID
|
|
355
403
|
target: e,
|
|
356
404
|
//地图容器中加载的图层
|
|
357
405
|
layers: [],
|
|
358
406
|
//地图视图设置
|
|
359
|
-
view: new
|
|
360
|
-
projection:
|
|
407
|
+
view: new fe({
|
|
408
|
+
projection: o.projection,
|
|
361
409
|
// 坐标系,有EPSG:4326和EPSG:3857
|
|
362
410
|
//地图初始中心点
|
|
363
|
-
center:
|
|
411
|
+
center: o.center,
|
|
364
412
|
// 坐标
|
|
365
413
|
//地图初始显示级别
|
|
366
|
-
zoom:
|
|
367
|
-
minZoom:
|
|
368
|
-
maxZoom:
|
|
414
|
+
zoom: o.zoom,
|
|
415
|
+
minZoom: o.minZoom,
|
|
416
|
+
maxZoom: o.maxZoom
|
|
417
|
+
}),
|
|
418
|
+
controls: Pe({
|
|
419
|
+
zoom: !1,
|
|
420
|
+
rotate: !1,
|
|
421
|
+
attribution: !1
|
|
369
422
|
})
|
|
370
423
|
});
|
|
371
|
-
return
|
|
424
|
+
return n.targetId = e, n;
|
|
372
425
|
}
|
|
373
|
-
function
|
|
374
|
-
|
|
426
|
+
function et(e, t, r, o) {
|
|
427
|
+
X(e, t, r, O(R({}, o), { type: "Point" }));
|
|
375
428
|
}
|
|
376
|
-
function
|
|
377
|
-
return new Promise((
|
|
429
|
+
function ee(e, t, r) {
|
|
430
|
+
return new Promise((o, n) => {
|
|
378
431
|
e.getView().animate(
|
|
379
432
|
{
|
|
380
433
|
center: t,
|
|
381
434
|
duration: r.duration || 1e3,
|
|
382
|
-
zoom: r.zoom ||
|
|
435
|
+
zoom: r.zoom || re(e),
|
|
383
436
|
rotation: r.rotation || 0,
|
|
384
437
|
easing: r.easing
|
|
385
438
|
},
|
|
386
|
-
|
|
439
|
+
o
|
|
387
440
|
);
|
|
388
441
|
});
|
|
389
442
|
}
|
|
390
|
-
function
|
|
391
|
-
const r = (t.extend[0] + t.extend[2]) / 2,
|
|
392
|
-
return
|
|
443
|
+
function te(e, t) {
|
|
444
|
+
const r = (t.extend[0] + t.extend[2]) / 2, o = (t.extend[1] + t.extend[3]) / 2;
|
|
445
|
+
return ee(e, [r, o], t);
|
|
393
446
|
}
|
|
394
|
-
function
|
|
395
|
-
const
|
|
396
|
-
return
|
|
447
|
+
function tt(e, t, r) {
|
|
448
|
+
const o = t.getGeometry().getExtent();
|
|
449
|
+
return te(e, O(R({}, r), { extend: o }));
|
|
397
450
|
}
|
|
398
|
-
function
|
|
451
|
+
function rt(e) {
|
|
399
452
|
return e.getView().getProjection();
|
|
400
453
|
}
|
|
401
|
-
function
|
|
454
|
+
function re(e) {
|
|
402
455
|
return e.getView().getZoom();
|
|
403
456
|
}
|
|
404
|
-
function
|
|
457
|
+
function nt(e, t) {
|
|
405
458
|
e.getView().setZoom(t);
|
|
406
459
|
}
|
|
407
|
-
function
|
|
460
|
+
function ot(e, t) {
|
|
408
461
|
e.un("click", () => {
|
|
409
462
|
}), e.un("pointermove", () => {
|
|
410
|
-
}),
|
|
463
|
+
}), Ye(t);
|
|
411
464
|
}
|
|
412
|
-
let
|
|
413
|
-
function
|
|
414
|
-
const r = new
|
|
415
|
-
|
|
416
|
-
condition:
|
|
465
|
+
let F = null;
|
|
466
|
+
function st(e, t = {}) {
|
|
467
|
+
const r = new I();
|
|
468
|
+
F = new Ee({
|
|
469
|
+
condition: ve,
|
|
417
470
|
multi: t.multi || !1,
|
|
418
|
-
style: (
|
|
471
|
+
style: (c) => {
|
|
419
472
|
if (typeof t.getStyle == "function") {
|
|
420
|
-
const
|
|
421
|
-
return t.getStyle(
|
|
473
|
+
const i = c.get("layerName");
|
|
474
|
+
return t.getStyle(i, c);
|
|
422
475
|
} else
|
|
423
476
|
return t.style;
|
|
424
477
|
},
|
|
425
478
|
// 高亮选中样式
|
|
426
479
|
// 过滤:只允许配置中的图层被选中 (仅对 Vector 有效)
|
|
427
|
-
layers: t.layers ? (
|
|
428
|
-
}), e.addInteraction(
|
|
429
|
-
const
|
|
430
|
-
const
|
|
480
|
+
layers: t.layers ? (c) => t.layers.includes(c) : void 0
|
|
481
|
+
}), e.addInteraction(F);
|
|
482
|
+
const o = F.getFeatures(), n = (c) => T(null, null, function* () {
|
|
483
|
+
const i = (t.layers || e.getLayers().getArray()).filter((w) => {
|
|
431
484
|
const h = w.getSource();
|
|
432
|
-
return w.getVisible() && (h instanceof
|
|
485
|
+
return w.getVisible() && (h instanceof N || h instanceof W);
|
|
433
486
|
});
|
|
434
|
-
if (
|
|
435
|
-
const
|
|
436
|
-
const f = w.getSource().getFeatureInfoUrl(
|
|
487
|
+
if (i.length === 0) return;
|
|
488
|
+
const l = e.getView(), m = i.map((w) => T(null, null, function* () {
|
|
489
|
+
const f = w.getSource().getFeatureInfoUrl(c.coordinate, l.getResolution(), l.getProjection(), {
|
|
437
490
|
INFO_FORMAT: "application/json",
|
|
438
491
|
// 必须是 JSON 才能转 Feature
|
|
439
492
|
FEATURE_COUNT: 1
|
|
@@ -444,52 +497,52 @@ function Qe(e, t = {}) {
|
|
|
444
497
|
if (b.features && b.features.length > 0) {
|
|
445
498
|
const d = r.readFeatures(b);
|
|
446
499
|
return d.forEach((y) => {
|
|
447
|
-
y.set("wms_layer_source", w), y.set("wms_event_source",
|
|
500
|
+
y.set("wms_layer_source", w), y.set("wms_event_source", c), y.set("layerName", w.get("name"));
|
|
448
501
|
}), d;
|
|
449
502
|
}
|
|
450
|
-
} catch (
|
|
451
|
-
console.warn(
|
|
503
|
+
} catch (L) {
|
|
504
|
+
console.warn(L);
|
|
452
505
|
}
|
|
453
506
|
return [];
|
|
454
|
-
})),
|
|
455
|
-
|
|
507
|
+
})), u = (yield Promise.all(m)).flat();
|
|
508
|
+
u.length > 0 && (t.multi, o.extend(u), F.dispatchEvent({
|
|
456
509
|
type: "select",
|
|
457
|
-
selected:
|
|
510
|
+
selected: u,
|
|
458
511
|
deselected: [],
|
|
459
|
-
mapBrowserEvent:
|
|
512
|
+
mapBrowserEvent: c
|
|
460
513
|
}));
|
|
461
514
|
});
|
|
462
|
-
e.on("singleclick",
|
|
515
|
+
e.on("singleclick", n);
|
|
463
516
|
const s = /* @__PURE__ */ new Set();
|
|
464
|
-
|
|
465
|
-
const
|
|
466
|
-
if (
|
|
467
|
-
const
|
|
517
|
+
F.on("select", (c) => {
|
|
518
|
+
const i = o.getArray();
|
|
519
|
+
if (i.length > 0) {
|
|
520
|
+
const l = i.map((m) => ({
|
|
468
521
|
feature: m,
|
|
469
522
|
properties: m.getProperties(),
|
|
470
523
|
// 如果是 WMS 注入的,我们在上面 set 过了;如果是 Vector,用 native 方法获取
|
|
471
|
-
layer: m.get("wms_layer_source") ||
|
|
472
|
-
event: m.get("wms_event_source") ||
|
|
524
|
+
layer: m.get("wms_layer_source") || F.getLayer(m),
|
|
525
|
+
event: m.get("wms_event_source") || c
|
|
473
526
|
}));
|
|
474
|
-
|
|
527
|
+
a(l);
|
|
475
528
|
} else
|
|
476
|
-
|
|
529
|
+
a(null);
|
|
477
530
|
});
|
|
478
|
-
const
|
|
531
|
+
const a = (c) => s.forEach((i) => i(c));
|
|
479
532
|
return {
|
|
480
|
-
onSelect: (
|
|
533
|
+
onSelect: (c) => (s.add(c), () => s.delete(c)),
|
|
481
534
|
clear: () => {
|
|
482
|
-
s.clear(),
|
|
535
|
+
s.clear(), o.clear();
|
|
483
536
|
},
|
|
484
537
|
destroy: () => {
|
|
485
|
-
e.removeInteraction(
|
|
538
|
+
e.removeInteraction(F), e.un("singleclick", n), s.clear();
|
|
486
539
|
}
|
|
487
540
|
};
|
|
488
541
|
}
|
|
489
|
-
function
|
|
490
|
-
var
|
|
491
|
-
const r = new
|
|
492
|
-
source:
|
|
542
|
+
function at(e, t = {}) {
|
|
543
|
+
var x;
|
|
544
|
+
const r = new I(), o = (x = t.debounceTime) != null ? x : 200, n = new M(), s = new E({
|
|
545
|
+
source: n,
|
|
493
546
|
map: e,
|
|
494
547
|
style: t.style,
|
|
495
548
|
// 直接透传用户的样式配置
|
|
@@ -498,33 +551,33 @@ function Ye(e, t = {}) {
|
|
|
498
551
|
properties: { title: "JG_HOVER_LAYER" }
|
|
499
552
|
// 标记一下,防止自己拾取自己
|
|
500
553
|
});
|
|
501
|
-
let
|
|
502
|
-
const
|
|
503
|
-
const f =
|
|
504
|
-
if (
|
|
505
|
-
if (
|
|
506
|
-
const
|
|
554
|
+
let a = null, c = null;
|
|
555
|
+
const i = /* @__PURE__ */ new Set(), l = (u, w, h) => {
|
|
556
|
+
const f = u[0];
|
|
557
|
+
if (a !== f)
|
|
558
|
+
if (a = f, n.clear(), f ? (n.addFeature(f), t.cursor !== !1 && (e.getTargetElement().style.cursor = "pointer")) : t.cursor !== !1 && (e.getTargetElement().style.cursor = ""), f) {
|
|
559
|
+
const L = {
|
|
507
560
|
feature: f,
|
|
508
561
|
layer: w,
|
|
509
562
|
properties: f.getProperties(),
|
|
510
563
|
coordinate: h
|
|
511
564
|
};
|
|
512
|
-
|
|
565
|
+
i.forEach((b) => b([L]));
|
|
513
566
|
} else
|
|
514
|
-
|
|
515
|
-
}, m = (
|
|
516
|
-
if (
|
|
517
|
-
const w =
|
|
567
|
+
i.forEach((L) => L(null));
|
|
568
|
+
}, m = (u) => {
|
|
569
|
+
if (u.dragging) return;
|
|
570
|
+
const w = u.pixel, h = u.coordinate;
|
|
518
571
|
let f = !1;
|
|
519
572
|
if (e.forEachFeatureAtPixel(w, (d, y) => {
|
|
520
|
-
f || y !== s && (t.layers && !t.layers.includes(y) || (f = !0,
|
|
573
|
+
f || y !== s && (t.layers && !t.layers.includes(y) || (f = !0, c && clearTimeout(c), l([d], y, h)));
|
|
521
574
|
}), f) return;
|
|
522
|
-
|
|
575
|
+
a && (a = null, n.clear(), e.getTargetElement().style.cursor = "", i.forEach((d) => d(null))), c && clearTimeout(c);
|
|
523
576
|
const b = (t.layers || e.getLayers().getArray()).filter((d) => {
|
|
524
577
|
const y = d.getSource();
|
|
525
|
-
return d.getVisible() && (y instanceof
|
|
578
|
+
return d.getVisible() && (y instanceof N || y instanceof W);
|
|
526
579
|
});
|
|
527
|
-
b.length !== 0 && (
|
|
580
|
+
b.length !== 0 && (c = setTimeout(() => T(null, null, function* () {
|
|
528
581
|
const d = e.getView();
|
|
529
582
|
for (const y of b) {
|
|
530
583
|
const _ = y.getSource().getFeatureInfoUrl(h, d.getResolution(), d.getProjection(), {
|
|
@@ -533,59 +586,67 @@ function Ye(e, t = {}) {
|
|
|
533
586
|
});
|
|
534
587
|
if (_)
|
|
535
588
|
try {
|
|
536
|
-
const
|
|
537
|
-
if (
|
|
538
|
-
const
|
|
539
|
-
|
|
589
|
+
const k = yield (yield fetch(_)).json();
|
|
590
|
+
if (k.features && k.features.length > 0) {
|
|
591
|
+
const C = r.readFeatures(k);
|
|
592
|
+
C.forEach((oe) => oe.set("wms_layer_source", y)), l(C, y, h);
|
|
540
593
|
return;
|
|
541
594
|
}
|
|
542
|
-
} catch (
|
|
595
|
+
} catch (ne) {
|
|
543
596
|
}
|
|
544
597
|
}
|
|
545
|
-
}),
|
|
598
|
+
}), o));
|
|
546
599
|
};
|
|
547
600
|
return e.on("pointermove", m), {
|
|
548
|
-
onHover: (
|
|
601
|
+
onHover: (u) => (i.add(u), () => i.delete(u)),
|
|
549
602
|
clear: () => {
|
|
550
|
-
|
|
603
|
+
n.clear(), a = null;
|
|
551
604
|
},
|
|
552
605
|
destroy: () => {
|
|
553
|
-
e.un("pointermove", m), e.removeLayer(s),
|
|
606
|
+
e.un("pointermove", m), e.removeLayer(s), i.clear(), c && clearTimeout(c);
|
|
554
607
|
}
|
|
555
608
|
};
|
|
556
609
|
}
|
|
557
|
-
const
|
|
558
|
-
const r =
|
|
559
|
-
|
|
560
|
-
const
|
|
610
|
+
const St = (e, t) => {
|
|
611
|
+
const r = Ke(e, t);
|
|
612
|
+
Ge(r, t.baseLayers);
|
|
613
|
+
const o = {
|
|
561
614
|
targetId: e,
|
|
562
615
|
instance: r,
|
|
563
616
|
// 暴露原始实例以备不时之需
|
|
564
|
-
addMarker: (
|
|
565
|
-
createLayer: (
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
617
|
+
addMarker: (n, s, a) => et(r, n, s, a),
|
|
618
|
+
createLayer: (n, s, a) => X(r, n, s, a),
|
|
619
|
+
createBlankLayer: (n, s) => Je(r, n, s),
|
|
620
|
+
visibleLayer: (n, s) => Qe(r, n, s),
|
|
621
|
+
removeLayer: (n) => qe(r, n),
|
|
622
|
+
getLonLat: (n) => p(n),
|
|
623
|
+
getLayerByName: (n) => Z(r, n),
|
|
624
|
+
getSourceByName: (n) => Q(r, n),
|
|
625
|
+
useSelect: (n) => st(r, n),
|
|
626
|
+
useHover: (n) => at(r, n),
|
|
627
|
+
queryFeature: (n, s) => Oe(r, n, s),
|
|
628
|
+
lightFeature: (n, s, a, c) => J(n, s, a, c),
|
|
629
|
+
flashFeature: (n, s, a) => Re(n, s, a),
|
|
630
|
+
flyTo: (n, s) => ee(r, n, s),
|
|
631
|
+
flyToByExtent: (n) => te(r, n),
|
|
632
|
+
flyToByFeature: (n, s) => tt(r, n, s),
|
|
633
|
+
getProjection: () => rt(r),
|
|
634
|
+
getZoom: () => re(r),
|
|
635
|
+
setZoom: (n) => nt(r, n),
|
|
636
|
+
getMapContext: (n) => Y(n),
|
|
637
|
+
onMapReady: (n, s) => K(n, s),
|
|
638
|
+
destroyMap: () => ot(r, e)
|
|
578
639
|
};
|
|
579
|
-
return
|
|
640
|
+
return Xe(e, o), o;
|
|
580
641
|
};
|
|
581
|
-
function
|
|
582
|
-
|
|
642
|
+
function xt(e, t) {
|
|
643
|
+
K(e, t);
|
|
583
644
|
}
|
|
584
|
-
function
|
|
585
|
-
return
|
|
645
|
+
function Pt(e) {
|
|
646
|
+
return Y(e);
|
|
586
647
|
}
|
|
587
648
|
export {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
649
|
+
Pt as getMapContext,
|
|
650
|
+
xt as onMapReady,
|
|
651
|
+
St as useMap
|
|
591
652
|
};
|