@summeruse/ol 0.2.0-alpha.0 → 0.2.0-alpha.1

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.
Files changed (70) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/index.js +689 -816
  3. package/es/components/index.mjs +3 -0
  4. package/es/components/ol-map/index.mjs +3 -0
  5. package/es/components/ol-map/index.vue_vue_type_script_setup_true_lang.mjs +114 -0
  6. package/es/components/ol-map/index2.mjs +2 -0
  7. package/es/components/ol-map/props.mjs +5 -8
  8. package/es/composables/common/index.mjs +4 -6
  9. package/es/composables/index.mjs +6 -0
  10. package/es/composables/useContextmenu/index.mjs +70 -76
  11. package/es/composables/useDrawLineString/index.mjs +104 -112
  12. package/es/composables/useDrawPolygon/index.mjs +105 -115
  13. package/es/composables/useGraticule/index.mjs +22 -36
  14. package/es/composables/usePointermove/index.mjs +100 -99
  15. package/es/composables/useSwitchBaseLayer/index.mjs +16 -24
  16. package/es/constants/distance.mjs +2 -4
  17. package/es/constants/projection.mjs +2 -7
  18. package/es/index.mjs +19 -76
  19. package/es/utils/distance/index.mjs +6 -9
  20. package/es/utils/feature/index.mjs +66 -82
  21. package/es/utils/index.d.ts +0 -3
  22. package/es/utils/index.mjs +5 -0
  23. package/es/utils/layer/index.d.ts +1 -1
  24. package/es/utils/layer/index.mjs +47 -60
  25. package/es/utils/projection/index.mjs +15 -24
  26. package/es/utils/style/index.mjs +27 -31
  27. package/lib/_virtual/rolldown_runtime.js +1 -0
  28. package/lib/components/index.js +1 -0
  29. package/lib/components/ol-map/index.js +1 -0
  30. package/lib/components/ol-map/index.vue_vue_type_script_setup_true_lang.js +1 -0
  31. package/lib/components/ol-map/index2.js +1 -0
  32. package/lib/components/ol-map/props.js +1 -1
  33. package/lib/composables/common/index.js +1 -1
  34. package/lib/composables/index.js +1 -0
  35. package/lib/composables/useContextmenu/index.js +1 -1
  36. package/lib/composables/useDrawLineString/index.js +1 -1
  37. package/lib/composables/useDrawPolygon/index.js +1 -1
  38. package/lib/composables/useGraticule/index.js +1 -1
  39. package/lib/composables/usePointermove/index.js +1 -1
  40. package/lib/composables/useSwitchBaseLayer/index.js +1 -1
  41. package/lib/constants/distance.js +1 -1
  42. package/lib/constants/projection.js +1 -1
  43. package/lib/index.js +1 -1
  44. package/lib/utils/distance/index.js +1 -1
  45. package/lib/utils/feature/index.js +1 -1
  46. package/lib/utils/index.d.ts +0 -3
  47. package/lib/utils/index.js +1 -0
  48. package/lib/utils/layer/index.d.ts +1 -1
  49. package/lib/utils/layer/index.js +1 -1
  50. package/lib/utils/projection/index.js +1 -1
  51. package/lib/utils/style/index.js +1 -1
  52. package/package.json +4 -11
  53. package/es/components/ol-map/index.vue.mjs +0 -124
  54. package/es/components/ol-map/index.vue2.mjs +0 -4
  55. package/es/utils/calculate/index.d.ts +0 -24
  56. package/es/utils/calculate/index.mjs +0 -29
  57. package/es/utils/calculate/index.test.d.ts +0 -1
  58. package/es/utils/format/index.d.ts +0 -4
  59. package/es/utils/format/index.mjs +0 -10
  60. package/es/utils/realCircle/index.d.ts +0 -9
  61. package/es/utils/realCircle/index.mjs +0 -10
  62. package/lib/components/ol-map/index.vue.js +0 -1
  63. package/lib/components/ol-map/index.vue2.js +0 -1
  64. package/lib/utils/calculate/index.d.ts +0 -24
  65. package/lib/utils/calculate/index.js +0 -1
  66. package/lib/utils/calculate/index.test.d.ts +0 -1
  67. package/lib/utils/format/index.d.ts +0 -4
  68. package/lib/utils/format/index.js +0 -1
  69. package/lib/utils/realCircle/index.d.ts +0 -9
  70. package/lib/utils/realCircle/index.js +0 -1
package/dist/index.js CHANGED
@@ -1,817 +1,690 @@
1
- import { inject as Re, defineComponent as Ze, ref as E, watch as p, provide as ze, createElementBlock as Ge, openBlock as _e, renderSlot as Be, unref as Ve, toValue as G, onBeforeUnmount as xe, computed as P, onMounted as Le, render as N, onUnmounted as Oe } from "vue";
2
- import { Map as je, View as De, Feature as J, Overlay as $ } from "ol";
3
- import { Zoom as ae, Attribution as se, Rotate as ue, FullScreen as fe, OverviewMap as de, ScaleLine as ye } from "ol/control";
4
- import { DragPan as me, MouseWheelZoom as ve, DoubleClickZoom as ge, PinchRotate as we, PinchZoom as pe, DragRotate as Se, KeyboardPan as he, KeyboardZoom as Ee, Draw as Pe, Modify as Ce } from "ol/interaction";
5
- import { Point as We, LineString as U, Polygon as H, Circle as Ne, MultiPoint as $e, MultiLineString as Xe, MultiPolygon as Ye } from "ol/geom";
6
- import ee from "ol/layer/Vector";
7
- import te from "ol/source/Vector";
8
- import { destination as Ke, lineString as Ue, length as He, area as Qe, polygon as qe, bearing as Je, midpoint as et } from "@turf/turf";
9
- import { Circle as tt, Stroke as _, Fill as X, Text as nt, Icon as ot, Style as rt } from "ol/style";
10
- import { Tile as ne, Graticule as it } from "ol/layer";
11
- import { XYZ as ct, BingMaps as lt, OSM as at } from "ol/source";
12
- import { transform as Fe, transformExtent as Ie } from "ol/proj";
13
- import { getCenter as st } from "ol/extent";
14
- const Te = Symbol("olMapInjectionKey");
15
- function _t() {
16
- return Re(Te);
17
- }
18
- const Bt = /* @__PURE__ */ Ze({
19
- __name: "index",
20
- props: {
21
- olMap: { default: () => new je() },
22
- center: { default: () => [0, 0] },
23
- zoom: { default: 2 },
24
- minZoom: { default: 2 },
25
- maxZoom: { default: 18 },
26
- constrainResolution: { type: Boolean, default: !0 },
27
- projection: {},
28
- extent: {},
29
- showZoom: { type: Boolean, default: !1 },
30
- showAttribution: { type: Boolean, default: !1 },
31
- showRotate: { type: Boolean, default: !1 },
32
- showFullScreen: { type: Boolean, default: !1 },
33
- showOverview: { type: Boolean, default: !1 },
34
- showScale: { type: Boolean, default: !1 },
35
- dragPan: { type: Boolean, default: !0 },
36
- mouseWheelZoom: { type: Boolean, default: !0 },
37
- doubleClickZoom: { type: Boolean, default: !1 },
38
- pinchRotate: { type: Boolean },
39
- pinchZoom: { type: Boolean },
40
- altShiftDragRotate: { type: Boolean }
41
- },
42
- setup(t, { expose: e }) {
43
- const o = t, i = E(), r = o.olMap, c = new De({
44
- projection: o.projection,
45
- extent: o.extent
46
- });
47
- r.setView(c), p(() => o.zoom, (n) => {
48
- c.setZoom(n);
49
- }, {
50
- immediate: !0
51
- }), p(() => o.center, (n) => {
52
- c.setCenter(n);
53
- }, {
54
- immediate: !0
55
- }), p(() => o.constrainResolution, (n) => {
56
- c.setConstrainResolution(n);
57
- }, {
58
- immediate: !0
59
- }), p(() => o.minZoom, (n) => {
60
- n && c.setMinZoom(n);
61
- }, {
62
- immediate: !0
63
- }), p(() => o.maxZoom, (n) => {
64
- n && c.setMaxZoom(n);
65
- }, {
66
- immediate: !0
67
- }), p(i, (n) => {
68
- n && r.setTarget(n);
69
- }), e({
70
- olMap: r
71
- }), ze(Te, r);
72
- const a = r.getControls().getArray(), w = a.find((n) => n instanceof ae) || new ae(), O = a.find((n) => n instanceof se) || new se(), y = a.find((n) => n instanceof ue) || new ue(), m = a.find((n) => n instanceof fe) || new fe(), h = a.find((n) => n instanceof de) || new de(), b = a.find((n) => n instanceof ye) || new ye();
73
- p(() => o.showZoom, (n) => {
74
- w.setMap(n ? r : null);
75
- }, {
76
- immediate: !0
77
- }), p(() => o.showAttribution, (n) => {
78
- O.setMap(n ? r : null);
79
- }, {
80
- immediate: !0
81
- }), p(() => o.showRotate, (n) => {
82
- y.setMap(n ? r : null);
83
- }, {
84
- immediate: !0
85
- }), p(() => o.showFullScreen, (n) => {
86
- m.setMap(n ? r : null);
87
- }, {
88
- immediate: !0
89
- }), p(() => o.showOverview, (n) => {
90
- h.setMap(n ? r : null);
91
- }, {
92
- immediate: !0
93
- }), p(() => o.showScale, (n) => {
94
- b.setMap(n ? r : null);
95
- }, {
96
- immediate: !0
97
- });
98
- const u = r.getInteractions().getArray(), f = u.find((n) => n instanceof me) || new me(), L = u.find((n) => n instanceof ve) || new ve(), s = u.find((n) => n instanceof ge) || new ge(), l = u.find((n) => n instanceof we) || new we(), v = u.find((n) => n instanceof pe) || new pe(), x = u.find((n) => n instanceof Se) || new Se(), d = u.find((n) => n instanceof he) || new he(), g = u.find((n) => n instanceof Ee) || new Ee();
99
- return r.removeInteraction(f), r.addInteraction(f), r.removeInteraction(L), r.addInteraction(L), r.removeInteraction(s), r.addInteraction(s), r.removeInteraction(l), r.addInteraction(l), r.removeInteraction(v), r.addInteraction(v), r.removeInteraction(x), r.addInteraction(x), r.removeInteraction(d), r.removeInteraction(g), p(() => o.dragPan, (n) => {
100
- f.setActive(n);
101
- }, {
102
- immediate: !0
103
- }), p(() => o.mouseWheelZoom, (n) => {
104
- L.setActive(n);
105
- }, {
106
- immediate: !0
107
- }), p(() => o.doubleClickZoom, (n) => {
108
- s.setActive(n);
109
- }, {
110
- immediate: !0
111
- }), p(() => o.pinchRotate, (n) => {
112
- l.setActive(n);
113
- }, {
114
- immediate: !0
115
- }), p(() => o.pinchZoom, (n) => {
116
- v.setActive(n);
117
- }, {
118
- immediate: !0
119
- }), p(() => o.altShiftDragRotate, (n) => {
120
- x.setActive(n);
121
- }, {
122
- immediate: !0
123
- }), (n, S) => (_e(), Ge("div", {
124
- ref_key: "mapRef",
125
- ref: i
126
- }, [
127
- Be(n.$slots, "default", {
128
- olMap: Ve(r),
129
- mapRef: i.value
130
- })
131
- ], 512));
132
- }
1
+ import { computed, createElementBlock, defineComponent, inject, onBeforeUnmount, onMounted, onUnmounted, openBlock, provide, ref, render, renderSlot, toValue, unref, watch } from "vue";
2
+ import { Feature, Map, Overlay, View } from "ol";
3
+ import { Attribution, FullScreen, OverviewMap, Rotate, ScaleLine, Zoom } from "ol/control";
4
+ import { DoubleClickZoom, DragPan, DragRotate, Draw, KeyboardPan, KeyboardZoom, Modify, MouseWheelZoom, PinchRotate, PinchZoom } from "ol/interaction";
5
+ import { getCenter } from "ol/extent";
6
+ import { Circle, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon } from "ol/geom";
7
+ import VectorLayer from "ol/layer/Vector";
8
+ import VectorSource from "ol/source/Vector";
9
+ import { Circle as Circle$1, Fill, Icon, Stroke, Style, Text } from "ol/style";
10
+ import { Graticule, Tile } from "ol/layer";
11
+ import { BingMaps, OSM, XYZ } from "ol/source";
12
+ import { transform, transformExtent } from "ol/proj";
13
+ const olMapInjectionKey = Symbol("olMapInjectionKey");
14
+ function useOlMap() {
15
+ return inject(olMapInjectionKey);
16
+ }
17
+ var ol_map_default = /* @__PURE__ */ defineComponent({
18
+ __name: "index",
19
+ props: {
20
+ olMap: { default: () => new Map() },
21
+ center: { default: () => [0, 0] },
22
+ zoom: { default: 2 },
23
+ minZoom: { default: 2 },
24
+ maxZoom: { default: 18 },
25
+ constrainResolution: {
26
+ type: Boolean,
27
+ default: !0
28
+ },
29
+ projection: {},
30
+ extent: {},
31
+ showZoom: {
32
+ type: Boolean,
33
+ default: !1
34
+ },
35
+ showAttribution: {
36
+ type: Boolean,
37
+ default: !1
38
+ },
39
+ showRotate: {
40
+ type: Boolean,
41
+ default: !1
42
+ },
43
+ showFullScreen: {
44
+ type: Boolean,
45
+ default: !1
46
+ },
47
+ showOverview: {
48
+ type: Boolean,
49
+ default: !1
50
+ },
51
+ showScale: {
52
+ type: Boolean,
53
+ default: !1
54
+ },
55
+ dragPan: {
56
+ type: Boolean,
57
+ default: !0
58
+ },
59
+ mouseWheelZoom: {
60
+ type: Boolean,
61
+ default: !0
62
+ },
63
+ doubleClickZoom: {
64
+ type: Boolean,
65
+ default: !1
66
+ },
67
+ pinchRotate: { type: Boolean },
68
+ pinchZoom: { type: Boolean },
69
+ altShiftDragRotate: { type: Boolean }
70
+ },
71
+ setup(e, { expose: x }) {
72
+ let S = e, C = ref(), w = S.olMap, T = new View({
73
+ projection: S.projection,
74
+ extent: S.extent
75
+ });
76
+ w.setView(T), watch(() => S.zoom, (e) => {
77
+ T.setZoom(e);
78
+ }, { immediate: !0 }), watch(() => S.center, (e) => {
79
+ T.setCenter(e);
80
+ }, { immediate: !0 }), watch(() => S.constrainResolution, (e) => {
81
+ T.setConstrainResolution(e);
82
+ }, { immediate: !0 }), watch(() => S.minZoom, (e) => {
83
+ e && T.setMinZoom(e);
84
+ }, { immediate: !0 }), watch(() => S.maxZoom, (e) => {
85
+ e && T.setMaxZoom(e);
86
+ }, { immediate: !0 }), watch(C, (e) => {
87
+ e && w.setTarget(e);
88
+ }), x({ olMap: w }), provide(olMapInjectionKey, w);
89
+ let k = w.getControls().getArray(), j = k.find((e) => e instanceof Zoom) || new Zoom(), P = k.find((e) => e instanceof Attribution) || new Attribution(), F = k.find((e) => e instanceof Rotate) || new Rotate(), I = k.find((e) => e instanceof FullScreen) || new FullScreen(), U = k.find((e) => e instanceof OverviewMap) || new OverviewMap(), W = k.find((e) => e instanceof ScaleLine) || new ScaleLine();
90
+ watch(() => S.showZoom, (e) => {
91
+ j.setMap(e ? w : null);
92
+ }, { immediate: !0 }), watch(() => S.showAttribution, (e) => {
93
+ P.setMap(e ? w : null);
94
+ }, { immediate: !0 }), watch(() => S.showRotate, (e) => {
95
+ F.setMap(e ? w : null);
96
+ }, { immediate: !0 }), watch(() => S.showFullScreen, (e) => {
97
+ I.setMap(e ? w : null);
98
+ }, { immediate: !0 }), watch(() => S.showOverview, (e) => {
99
+ U.setMap(e ? w : null);
100
+ }, { immediate: !0 }), watch(() => S.showScale, (e) => {
101
+ W.setMap(e ? w : null);
102
+ }, { immediate: !0 });
103
+ let G = w.getInteractions().getArray(), K = G.find((e) => e instanceof DragPan) || new DragPan(), q = G.find((e) => e instanceof MouseWheelZoom) || new MouseWheelZoom(), J = G.find((e) => e instanceof DoubleClickZoom) || new DoubleClickZoom(), Y = G.find((e) => e instanceof PinchRotate) || new PinchRotate(), X = G.find((e) => e instanceof PinchZoom) || new PinchZoom(), Z = G.find((e) => e instanceof DragRotate) || new DragRotate(), Q = G.find((e) => e instanceof KeyboardPan) || new KeyboardPan(), $ = G.find((e) => e instanceof KeyboardZoom) || new KeyboardZoom();
104
+ return w.removeInteraction(K), w.addInteraction(K), w.removeInteraction(q), w.addInteraction(q), w.removeInteraction(J), w.addInteraction(J), w.removeInteraction(Y), w.addInteraction(Y), w.removeInteraction(X), w.addInteraction(X), w.removeInteraction(Z), w.addInteraction(Z), w.removeInteraction(Q), w.removeInteraction($), watch(() => S.dragPan, (e) => {
105
+ K.setActive(e);
106
+ }, { immediate: !0 }), watch(() => S.mouseWheelZoom, (e) => {
107
+ q.setActive(e);
108
+ }, { immediate: !0 }), watch(() => S.doubleClickZoom, (e) => {
109
+ J.setActive(e);
110
+ }, { immediate: !0 }), watch(() => S.pinchRotate, (e) => {
111
+ Y.setActive(e);
112
+ }, { immediate: !0 }), watch(() => S.pinchZoom, (e) => {
113
+ X.setActive(e);
114
+ }, { immediate: !0 }), watch(() => S.altShiftDragRotate, (e) => {
115
+ Z.setActive(e);
116
+ }, { immediate: !0 }), (e, x) => (openBlock(), createElementBlock("div", {
117
+ ref_key: "mapRef",
118
+ ref: C
119
+ }, [renderSlot(e.$slots, "default", {
120
+ olMap: unref(w),
121
+ mapRef: C.value
122
+ })], 512));
123
+ }
133
124
  });
134
- function Vt(t, e) {
135
- const o = E(!1), i = E({ x: 0, y: 0 }), r = E(), c = E([]), a = E();
136
- let w;
137
- function O(u, f) {
138
- const L = [];
139
- return u.filter((s) => {
140
- const l = s.visible;
141
- return typeof l == "function" ? l(f) : l ?? !0;
142
- }).filter((s) => !s.children || s.children.length > 0).sort((s, l) => (s.order ?? 0) - (l.order ?? 0)).forEach((s) => {
143
- const l = s.icon, v = s.label;
144
- L.push({
145
- ...s,
146
- children: s.children ? O(s.children, f) : void 0,
147
- visible: !0,
148
- action: () => {
149
- var x;
150
- (x = s.action) == null || x.call(s, f), m();
151
- },
152
- icon: typeof l == "function" ? () => l(f) : l,
153
- label: typeof v == "function" ? () => v(f) : v,
154
- disabled: typeof s.disabled == "function" ? s.disabled(f) : s.disabled ?? !1
155
- });
156
- }), L;
157
- }
158
- function y(u) {
159
- if (u.preventDefault(), !w)
160
- return;
161
- const f = w.getEventCoordinate(u);
162
- a.value = f;
163
- const L = w.getEventPixel(u);
164
- let s, l;
165
- w.forEachFeatureAtPixel(L, (d, g) => (s = d, l = g, !0)), r.value = s;
166
- const [v, x] = [u.clientX, u.clientY];
167
- i.value = { x: v, y: x }, c.value = O(G(e), {
168
- map: w,
169
- position: { ...i.value },
170
- coordinate: f,
171
- feature: s,
172
- layer: l
173
- }), o.value = !0;
174
- }
175
- function m() {
176
- o.value = !1;
177
- }
178
- function h(u) {
179
- if (!u)
180
- return;
181
- const f = u.getViewport();
182
- f.addEventListener("contextmenu", y), f.addEventListener("click", m);
183
- }
184
- function b(u) {
185
- if (!u)
186
- return;
187
- const f = u.getViewport();
188
- f.removeEventListener("contextmenu", y), f.removeEventListener("click", m);
189
- }
190
- return p(
191
- () => G(t),
192
- (u, f) => {
193
- f !== u && (b(f), h(u), w = u);
194
- },
195
- { immediate: !0 }
196
- ), xe(() => {
197
- b(w);
198
- }), {
199
- visible: P(() => o.value),
200
- position: P(() => i.value),
201
- feature: P(() => r.value),
202
- options: P(() => c.value),
203
- coordinate: P(() => a.value),
204
- hide: m
205
- };
206
- }
207
- function Q(t) {
208
- return t < 0 ? Q(t + 360) : t > 360 ? Q(t - 360) : t;
209
- }
210
- function q(t) {
211
- return t < -180 ? q(t + 360) : t > 180 ? q(t - 360) : t;
212
- }
213
- function ut(t, e, o) {
214
- return Ke(t, e, q(o), { units: "meters" }).geometry.coordinates;
215
- }
216
- function jt(t) {
217
- const e = Ue(t);
218
- return He(e, { units: "meters" });
219
- }
220
- function Dt(t) {
221
- return Qe(qe(t));
222
- }
223
- function Wt(t, e) {
224
- return Q(Je(t, e));
225
- }
226
- function ft(t, e) {
227
- return et(t, e).geometry.coordinates;
228
- }
229
- function ke(t) {
230
- return ft([t[0], t[1]], [t[2], t[3]]);
231
- }
232
- const Ae = 1852, B = "EPSG:3857", V = "EPSG:4326", be = B, dt = V;
233
- function Nt(t) {
234
- return t * 1e3 / Ae;
235
- }
236
- function $t(t) {
237
- return t * Ae / 1e3;
238
- }
239
- function yt(t) {
240
- const { fillOptions: e, strokeOptions: o, ...i } = t;
241
- return new tt({
242
- ...i,
243
- fill: e ? new X(e) : void 0,
244
- stroke: o ? new _(o) : void 0
245
- });
246
- }
247
- function W(t) {
248
- const { fillOptions: e, strokeOptions: o, backgroundFillOptions: i, backgroundStrokeOptions: r, ...c } = t;
249
- return new nt({
250
- ...c,
251
- fill: e ? new X(e) : void 0,
252
- stroke: o ? new _(o) : void 0,
253
- backgroundFill: i ? new X(i) : void 0,
254
- backgroundStroke: r ? new _(r) : void 0
255
- });
256
- }
257
- function T(t) {
258
- const { fillOptions: e, strokeOptions: o, iconOptions: i, circleOptions: r, textOptions: c, ...a } = t, w = e ? new X(e) : void 0, O = o ? new _(o) : void 0, y = i ? new ot(i) : void 0, m = r ? yt(r) : void 0, h = c ? W(c) : void 0;
259
- return new rt({
260
- ...a,
261
- fill: w,
262
- stroke: O,
263
- image: y || m,
264
- text: h
265
- });
266
- }
267
- function mt(t) {
268
- return new We(t);
269
- }
270
- function vt(t) {
271
- return new U(t);
272
- }
273
- function gt(t) {
274
- return new H(t);
275
- }
276
- function wt(t, e) {
277
- return new Ne(t, e);
278
- }
279
- function pt(t) {
280
- return new $e(t);
281
- }
282
- function St(t) {
283
- return new Xe(t);
284
- }
285
- function ht(t) {
286
- return new Ye(t);
287
- }
288
- function M(t) {
289
- const { styleOptions: e, style: o, geometry: i, ...r } = t ?? {}, c = e ? T(e) : o, a = new J({
290
- geometry: i,
291
- ...r
292
- });
293
- return a.setStyle(c), a;
294
- }
295
- function Xt(t, e) {
296
- const o = mt(t);
297
- return M({
298
- ...e,
299
- geometry: o
300
- });
301
- }
302
- function Yt(t, e) {
303
- const o = vt(t);
304
- return M({
305
- ...e,
306
- geometry: o
307
- });
308
- }
309
- function Kt(t, e) {
310
- const o = gt(t);
311
- return M({
312
- ...e,
313
- geometry: o
314
- });
315
- }
316
- function Ut(t, e, o) {
317
- const i = wt(t, e);
318
- return M({
319
- ...o,
320
- geometry: i
321
- });
322
- }
323
- function Ht(t, e) {
324
- const o = pt(t);
325
- return M({
326
- ...e,
327
- geometry: o
328
- });
329
- }
330
- function Qt(t, e) {
331
- const o = St(t);
332
- return M({
333
- ...e,
334
- geometry: o
335
- });
336
- }
337
- function qt(t, e) {
338
- const o = ht(t);
339
- return M({
340
- ...e,
341
- geometry: o
342
- });
343
- }
344
- function Et(t) {
345
- const { type: e = "img", projection: o = be, key: i } = t, r = t.url || "https://t{0-4}.tianditu.gov.cn", c = `&tk=${i}&SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}`;
346
- return `${r}/${e}_${o === dt ? "c" : o === be ? "w" : "c"}/wmts?LAYER=${e}${c}`;
347
- }
348
- function Jt(t) {
349
- const { zIndex: e, projection: o, className: i } = t;
350
- return new ne({
351
- className: i,
352
- source: new ct({
353
- url: Et(t),
354
- projection: o,
355
- crossOrigin: "Anonymous"
356
- }),
357
- zIndex: e
358
- });
359
- }
360
- function en({
361
- name: t,
362
- zIndex: e,
363
- key: o,
364
- className: i
365
- }) {
366
- return new ne({
367
- className: i,
368
- source: new lt({
369
- key: o,
370
- imagerySet: t,
371
- placeholderTiles: !1
372
- }),
373
- zIndex: e
374
- });
375
- }
376
- function tn(t) {
377
- return new ne({
378
- className: t == null ? void 0 : t.className,
379
- source: new at({
380
- crossOrigin: "Anonymous"
381
- }),
382
- zIndex: t == null ? void 0 : t.zIndex
383
- });
384
- }
385
- function nn(t) {
386
- const { styleOptions: e, ...o } = t || {}, i = e ? T(e) : void 0, r = new te(), c = new ee({
387
- source: r,
388
- ...o,
389
- style: i || o.style
390
- });
391
- return {
392
- source: r,
393
- layer: c
394
- };
395
- }
396
- function oe(t) {
397
- return Fe(t, V, B);
398
- }
399
- const on = oe;
400
- function bt(t) {
401
- return Fe(t, B, V);
402
- }
403
- const rn = bt;
404
- function xt(t) {
405
- return Ie(t, V, B);
406
- }
407
- const cn = xt;
408
- function re(t) {
409
- return Ie(t, B, V);
410
- }
411
- const ln = re;
412
- function an(t, e, o = 60) {
413
- const i = [], r = 360 / o;
414
- for (let c = -180; c < 180; c = c + r)
415
- i.push(ut(t, e, c));
416
- return [i];
417
- }
418
- function Y(t) {
419
- const e = document.createElement("div");
420
- return e.innerHTML = t, e.style.cursor = "pointer", e.style.userSelect = "none", e.style.backgroundColor = "red", e.style.color = "white", e.style.borderRadius = "5px", e.style.padding = "0 5px", e.style.fontSize = "12px", e.style.border = "2px solid white", e;
421
- }
422
- function sn(t, e) {
423
- const o = E(!0), i = E([]), r = P(() => i.value.map((d) => d.getGeometry().getCoordinates())), c = new te(), a = e.styleOptions ? T(e.styleOptions) : e == null ? void 0 : e.style, w = new ee({
424
- source: c,
425
- style: a,
426
- zIndex: e == null ? void 0 : e.zIndex
427
- });
428
- t.addLayer(w);
429
- const O = e.drawStyleOptions ? T(e.drawStyleOptions) : e == null ? void 0 : e.drawStyle, y = new Pe({
430
- source: c,
431
- style: O || a,
432
- type: "LineString"
433
- });
434
- y.setActive(!1);
435
- const m = e.modifyStyleOptions ? T(e.modifyStyleOptions) : e == null ? void 0 : e.modifyStyle, h = new Ce({
436
- source: c,
437
- style: m || a
438
- }), b = /* @__PURE__ */ new Set();
439
- t.addInteraction(y), Le(() => {
440
- t.addInteraction(h);
441
- }), c.on("addfeature", () => {
442
- e.size && c.getFeatures().length >= e.size && y.setActive(!1);
443
- }), c.on("removefeature", () => {
444
- e.size && c.getFeatures().length < e.size && y.setActive(!0);
445
- });
446
- const u = () => {
447
- b.forEach((d) => {
448
- t.removeOverlay(d);
449
- }), b.clear();
450
- };
451
- c.on("change", () => {
452
- u(), c.getFeatures().forEach((d) => {
453
- const g = d.getGeometry(), n = ke(re(g.getExtent()));
454
- let S = document.createElement("div");
455
- e.deleteFeatureLabel ? N(e.deleteFeatureLabel, S) : S = Y("删除线"), S.addEventListener("click", () => {
456
- c.removeFeature(d);
457
- });
458
- const k = new $({
459
- position: oe(n),
460
- positioning: "center-center",
461
- element: S
462
- });
463
- b.add(k), t.addOverlay(k);
464
- const F = g.getCoordinates();
465
- F.length < 3 || F.forEach((z, R) => {
466
- let C = document.createElement("div");
467
- e.deletePointLabel ? N(e.deletePointLabel, C) : C = Y("删除点"), C.addEventListener("click", () => {
468
- d.setGeometry(new U(F.filter((j, Z) => Z !== R)));
469
- });
470
- const I = new $({
471
- position: z,
472
- positioning: "top-center",
473
- offset: [0, -30],
474
- element: C
475
- });
476
- b.add(I), t.addOverlay(I);
477
- });
478
- });
479
- }), y.on("change:active", () => {
480
- o.value = y.getActive();
481
- }), c.on("change", () => {
482
- i.value = c.getFeatures();
483
- });
484
- const f = () => {
485
- u(), t.removeLayer(w), t.removeInteraction(y), t.removeInteraction(h);
486
- }, L = () => {
487
- e.size && i.value.length >= e.size || y.setActive(!0);
488
- }, s = () => {
489
- y.setActive(!1);
490
- }, l = (d) => {
491
- c.clear(), d.forEach((g) => {
492
- if (g.length < 2)
493
- return;
494
- const n = new J({
495
- geometry: new U(g)
496
- });
497
- c.addFeature(n);
498
- });
499
- }, v = () => {
500
- l(e.defaultCoordinates || []);
501
- };
502
- v();
503
- const x = () => {
504
- c.clear(), s();
505
- };
506
- return Oe(() => {
507
- f();
508
- }), {
509
- inDraw: o,
510
- start: L,
511
- stop: s,
512
- clear: x,
513
- setFeatures: l,
514
- reset: v,
515
- features: i,
516
- coordinates: r,
517
- destroy: f
518
- };
519
- }
520
- function un(t, e) {
521
- const o = E(!0), i = E([]), r = P(() => i.value.map((d) => d.getGeometry().getCoordinates())), c = e.styleOptions ? T(e.styleOptions) : e == null ? void 0 : e.style, a = new te(), w = new ee({
522
- source: a,
523
- style: c,
524
- zIndex: e == null ? void 0 : e.zIndex
525
- });
526
- t.addLayer(w);
527
- const O = e.drawStyleOptions ? T(e.drawStyleOptions) : e == null ? void 0 : e.drawStyle, y = new Pe({
528
- source: a,
529
- style: O || c,
530
- type: "Polygon"
531
- });
532
- y.setActive(!1);
533
- const m = e.modifyStyleOptions ? T(e.modifyStyleOptions) : e == null ? void 0 : e.modifyStyle, h = new Ce({
534
- source: a,
535
- style: m || c
536
- }), b = /* @__PURE__ */ new Set();
537
- t.addInteraction(y), Le(() => {
538
- t.addInteraction(h);
539
- }), a.on("addfeature", () => {
540
- e.size && a.getFeatures().length >= e.size && y.setActive(!1);
541
- }), a.on("removefeature", () => {
542
- e.size && a.getFeatures().length < e.size && y.setActive(!0);
543
- });
544
- const u = () => {
545
- b.forEach((d) => {
546
- t.removeOverlay(d);
547
- }), b.clear();
548
- };
549
- a.on("change", () => {
550
- u(), a.getFeatures().forEach((d) => {
551
- const g = d.getGeometry(), n = ke(re(g.getExtent()));
552
- let S = document.createElement("div");
553
- e.deleteFeatureLabel ? N(e.deleteFeatureLabel, S) : S = Y("删除区域"), S.addEventListener("click", () => {
554
- a.removeFeature(d);
555
- });
556
- const k = new $({
557
- position: oe(n),
558
- positioning: "center-center",
559
- element: S
560
- });
561
- b.add(k), t.addOverlay(k);
562
- const F = g.getCoordinates()[0];
563
- F.length < 3 || F.forEach((z, R) => {
564
- let C = document.createElement("div");
565
- e.deletePointLabel ? N(e.deletePointLabel, C) : C = Y("删除点"), C.addEventListener("click", () => {
566
- d.setGeometry(new H([F.filter((j, Z) => Z !== R)]));
567
- });
568
- const I = new $({
569
- position: z,
570
- positioning: "top-center",
571
- offset: [0, -30],
572
- element: C
573
- });
574
- b.add(I), t.addOverlay(I);
575
- });
576
- });
577
- }), y.on("change:active", () => {
578
- o.value = y.getActive();
579
- }), a.on("change", () => {
580
- i.value = a.getFeatures();
581
- });
582
- const f = () => {
583
- u(), t.removeLayer(w), t.removeInteraction(y), t.removeInteraction(h);
584
- }, L = () => {
585
- e.size && i.value.length >= e.size || y.setActive(!0);
586
- }, s = () => {
587
- y.setActive(!1);
588
- }, l = (d) => {
589
- a.clear(), d == null || d.forEach((g) => {
590
- g.forEach((n) => {
591
- if (n.length < 2)
592
- return;
593
- n[0] !== n[n.length - 1] && n.push(n[0]);
594
- const S = new J({
595
- geometry: new H([n])
596
- });
597
- a.addFeature(S);
598
- });
599
- });
600
- }, v = () => {
601
- l(e.defaultCoordinates);
602
- };
603
- v();
604
- const x = () => {
605
- a.clear(), s();
606
- };
607
- return Oe(() => {
608
- f();
609
- }), {
610
- inDraw: o,
611
- start: L,
612
- stop: s,
613
- clear: x,
614
- setFeatures: l,
615
- reset: v,
616
- features: i,
617
- coordinates: r,
618
- destroy: f
619
- };
620
- }
621
- function fn(t) {
622
- const e = E(t.defaultShow || !1), { strokeStyleOption: o, strokeStyle: i, labelStyleOption: r, latLabelStyleOption: c, lonLabelStyleOption: a, latLabelStyle: w, lonLabelStyle: O, ...y } = t.graticuleOptions || {}, m = o ? new _(o) : i, h = r ? W(r) : void 0, b = (c ? W(c) : w) || h, u = (a ? W(a) : O) || h, f = new it({
623
- ...y,
624
- strokeStyle: m,
625
- latLabelStyle: b,
626
- lonLabelStyle: u
627
- });
628
- return p(
629
- e,
630
- (L) => {
631
- if (f.setMap(null), L) {
632
- const s = G(t.olMap);
633
- s && f.setMap(s);
634
- }
635
- },
636
- {
637
- immediate: !0,
638
- deep: !0
639
- }
640
- ), {
641
- showGraticule: e
642
- };
643
- }
644
- function dn(t, e) {
645
- const o = E(!1), i = E({ x: 0, y: 0 }), r = E(), c = E(), a = E({ x: 0, y: 0 }), w = E(), O = E(), y = P(() => ({
646
- x: i.value.x + a.value.x,
647
- y: i.value.y + a.value.y
648
- }));
649
- let m, h = "";
650
- function b(l) {
651
- const x = G(e).filter((d) => {
652
- const g = d.visible;
653
- return typeof g == "function" ? g(l) : g ?? !0;
654
- });
655
- return x.length === 0 ? null : x.sort((d, g) => (g.priority ?? 0) - (d.priority ?? 0))[0];
656
- }
657
- function u(l) {
658
- var Z, ie;
659
- if (!m)
660
- return;
661
- const v = m.getEventCoordinate(l);
662
- w.value = v;
663
- const x = m.getEventPixel(l);
664
- let d, g;
665
- if (m.forEachFeatureAtPixel(x, (A, D) => (d = A, g = D, !0)), !d) {
666
- f();
667
- return;
668
- }
669
- r.value = d;
670
- const n = {
671
- map: m,
672
- position: { x: l.clientX, y: l.clientY },
673
- coordinate: v,
674
- feature: d,
675
- layer: g
676
- }, S = b(n);
677
- if (S) {
678
- const { content: A, cursor: D, visible: K, fixedFeatureCenter: ce, offset: le, priority: Lt, ...Me } = S;
679
- O.value = { ...Me };
680
- }
681
- if (!S) {
682
- f();
683
- return;
684
- }
685
- const k = ((Z = S.offset) == null ? void 0 : Z.x) ?? 0, F = ((ie = S.offset) == null ? void 0 : ie.y) ?? 0;
686
- a.value = { x: k, y: F };
687
- const z = S.fixedFeatureCenter ?? !0, R = d.getGeometry();
688
- if (z && R) {
689
- const A = R.getExtent(), D = st(A), K = m.getPixelFromCoordinate(D), { top: ce, left: le } = m.getViewport().getBoundingClientRect();
690
- i.value.x = K[0] + le, i.value.y = K[1] + ce;
691
- } else
692
- i.value = { x: l.clientX, y: l.clientY };
693
- const C = S.content;
694
- c.value = typeof C == "function" ? () => C(n) : C;
695
- const I = S.cursor, j = typeof I == "function" ? I(n) : I;
696
- if (j && m) {
697
- const A = m.getViewport();
698
- h || (h = A.style.cursor), A.style.cursor = j;
699
- }
700
- o.value = !0;
701
- }
702
- function f() {
703
- if (o.value = !1, r.value = void 0, m && h !== void 0) {
704
- const l = m.getViewport();
705
- l.style.cursor = h, h = "";
706
- }
707
- }
708
- function L(l) {
709
- if (!l)
710
- return;
711
- const v = l.getViewport();
712
- v.addEventListener("pointermove", u), v.addEventListener("pointerout", f);
713
- }
714
- function s(l) {
715
- if (!l)
716
- return;
717
- const v = l.getViewport();
718
- v.removeEventListener("pointermove", u), v.removeEventListener("pointerout", f);
719
- }
720
- return p(
721
- () => G(t),
722
- (l, v) => {
723
- v !== l && (s(v), L(l), m = l);
724
- },
725
- { immediate: !0 }
726
- ), xe(() => {
727
- s(m);
728
- }), {
729
- visible: P(() => o.value),
730
- position: P(() => y.value),
731
- originalPosition: P(() => i.value),
732
- feature: P(() => r.value),
733
- content: P(() => c.value),
734
- coordinate: P(() => w.value),
735
- option: P(() => O.value),
736
- hide: f
737
- };
738
- }
739
- function yn(t) {
740
- const e = E(t.defaultLayerName || Object.keys(t.layers)[0]);
741
- return Object.values(t.layers).forEach((o) => {
742
- o.forEach((i) => {
743
- t.olMap.addLayer(i);
744
- });
745
- }), p(
746
- e,
747
- () => {
748
- Object.entries(t.layers).forEach(([o, i]) => {
749
- const r = o === e.value;
750
- i.forEach((c) => {
751
- c.setVisible(r);
752
- });
753
- });
754
- },
755
- {
756
- immediate: !0
757
- }
758
- ), { visibleLayerName: e };
759
- }
760
- export {
761
- B as EPSG_3857,
762
- ln as EPSG_3857ExtentToEPSG_4326,
763
- rn as EPSG_3857ToEPSG_4326,
764
- V as EPSG_4326,
765
- cn as EPSG_4326ExtentToEPSG_3857,
766
- on as EPSG_4326ToEPSG_3857,
767
- Ae as ONE_NM,
768
- Bt as OlMap,
769
- dt as WGS84Projection,
770
- be as WebMercatorProjection,
771
- wt as createCircle,
772
- Ut as createCircleFeature,
773
- yt as createCircleStyle,
774
- M as createFeature,
775
- vt as createLineString,
776
- Yt as createLineStringFeature,
777
- St as createMultiLineString,
778
- Qt as createMultiLineStringFeature,
779
- pt as createMultiPoint,
780
- Ht as createMultiPointFeature,
781
- ht as createMultiPolygon,
782
- qt as createMultiPolygonFeature,
783
- mt as createPoint,
784
- Xt as createPointFeature,
785
- gt as createPolygon,
786
- Kt as createPolygonFeature,
787
- T as createStyle,
788
- W as createTextStyle,
789
- nn as createVectorLayer,
790
- Wt as getAngle,
791
- Dt as getArea,
792
- en as getBingLayer,
793
- ft as getCenter,
794
- ut as getDestinationPoint,
795
- ke as getExtentCenter,
796
- jt as getLineLength,
797
- tn as getOSMLayer,
798
- an as getRealCircleCoordinates,
799
- Jt as getTianDiTuLayer,
800
- Et as getTianDiTuUrl,
801
- Nt as kmToNauticalMiles,
802
- re as mercatorExtentToWgs84,
803
- bt as mercatorToWgs84,
804
- $t as nauticalMilesToKm,
805
- Te as olMapInjectionKey,
806
- Q as toOlAngle,
807
- q as toTurfAngle,
808
- Vt as useContextmenu,
809
- sn as useDrawLineString,
810
- un as useDrawPolygon,
811
- fn as useGraticule,
812
- _t as useOlMap,
813
- dn as usePointermove,
814
- yn as useSwitchBaseLayer,
815
- xt as wgs84ExtentToMercator,
816
- oe as wgs84ToMercator
817
- };
125
+ function useContextmenu(b, x) {
126
+ let S = ref(!1), w = ref({
127
+ x: 0,
128
+ y: 0
129
+ }), T = ref(), E = ref([]), D = ref(), k;
130
+ function A(e, b) {
131
+ let x = [];
132
+ return e.filter((e) => {
133
+ let x = e.visible;
134
+ return typeof x == "function" ? x(b) : x ?? !0;
135
+ }).filter((e) => !e.children || e.children.length > 0).sort((e, b) => (e.order ?? 0) - (b.order ?? 0)).forEach((e) => {
136
+ let S = e.icon, C = e.label;
137
+ x.push({
138
+ ...e,
139
+ children: e.children ? A(e.children, b) : void 0,
140
+ visible: !0,
141
+ action: () => {
142
+ e.action?.(b), P();
143
+ },
144
+ icon: typeof S == "function" ? () => S(b) : S,
145
+ label: typeof C == "function" ? () => C(b) : C,
146
+ disabled: typeof e.disabled == "function" ? e.disabled(b) : e.disabled ?? !1
147
+ });
148
+ }), x;
149
+ }
150
+ function M(e) {
151
+ if (e.preventDefault(), !k) return;
152
+ let b = k.getEventCoordinate(e);
153
+ D.value = b;
154
+ let C = k.getEventPixel(e), O, M;
155
+ k.forEachFeatureAtPixel(C, (e, b) => (O = e, M = b, !0)), T.value = O;
156
+ let [N, P] = [e.clientX, e.clientY];
157
+ w.value = {
158
+ x: N,
159
+ y: P
160
+ }, E.value = A(toValue(x), {
161
+ map: k,
162
+ position: { ...w.value },
163
+ coordinate: b,
164
+ feature: O,
165
+ layer: M
166
+ }), S.value = !0;
167
+ }
168
+ function P() {
169
+ S.value = !1;
170
+ }
171
+ function F(e) {
172
+ if (!e) return;
173
+ let b = e.getViewport();
174
+ b.addEventListener("contextmenu", M), b.addEventListener("click", P);
175
+ }
176
+ function I(e) {
177
+ if (!e) return;
178
+ let b = e.getViewport();
179
+ b.removeEventListener("contextmenu", M), b.removeEventListener("click", P);
180
+ }
181
+ return watch(() => toValue(b), (e, b) => {
182
+ b !== e && (I(b), F(e), k = e);
183
+ }, { immediate: !0 }), onBeforeUnmount(() => {
184
+ I(k);
185
+ }), {
186
+ visible: computed(() => S.value),
187
+ position: computed(() => w.value),
188
+ feature: computed(() => T.value),
189
+ options: computed(() => E.value),
190
+ coordinate: computed(() => D.value),
191
+ hide: P
192
+ };
193
+ }
194
+ const ONE_NM = 1852, EPSG_3857 = "EPSG:3857", EPSG_4326 = "EPSG:4326", WebMercatorProjection = EPSG_3857, WGS84Projection = EPSG_4326;
195
+ function kmToNauticalMiles(e) {
196
+ return e * 1e3 / ONE_NM;
197
+ }
198
+ function nauticalMilesToKm(e) {
199
+ return e * ONE_NM / 1e3;
200
+ }
201
+ function createCircleStyle(e) {
202
+ let { fillOptions: b, strokeOptions: x,...S } = e;
203
+ return new Circle$1({
204
+ ...S,
205
+ fill: b ? new Fill(b) : void 0,
206
+ stroke: x ? new Stroke(x) : void 0
207
+ });
208
+ }
209
+ function createTextStyle(e) {
210
+ let { fillOptions: b, strokeOptions: x, backgroundFillOptions: S, backgroundStrokeOptions: C,...w } = e;
211
+ return new Text({
212
+ ...w,
213
+ fill: b ? new Fill(b) : void 0,
214
+ stroke: x ? new Stroke(x) : void 0,
215
+ backgroundFill: S ? new Fill(S) : void 0,
216
+ backgroundStroke: C ? new Stroke(C) : void 0
217
+ });
218
+ }
219
+ function createStyle(e) {
220
+ let { fillOptions: b, strokeOptions: x, iconOptions: S, circleOptions: C, textOptions: w,...T } = e, E = b ? new Fill(b) : void 0, D = x ? new Stroke(x) : void 0, O = S ? new Icon(S) : void 0, k = C ? createCircleStyle(C) : void 0, A = w ? createTextStyle(w) : void 0;
221
+ return new Style({
222
+ ...T,
223
+ fill: E,
224
+ stroke: D,
225
+ image: O || k,
226
+ text: A
227
+ });
228
+ }
229
+ function createPoint(e) {
230
+ return new Point(e);
231
+ }
232
+ function createLineString(e) {
233
+ return new LineString(e);
234
+ }
235
+ function createPolygon(e) {
236
+ return new Polygon(e);
237
+ }
238
+ function createCircle(e, b) {
239
+ return new Circle(e, b);
240
+ }
241
+ function createMultiPoint(e) {
242
+ return new MultiPoint(e);
243
+ }
244
+ function createMultiLineString(e) {
245
+ return new MultiLineString(e);
246
+ }
247
+ function createMultiPolygon(e) {
248
+ return new MultiPolygon(e);
249
+ }
250
+ function createFeature(e) {
251
+ let { styleOptions: b, style: x, geometry: S,...C } = e ?? {}, w = b ? createStyle(b) : x, T = new Feature({
252
+ geometry: S,
253
+ ...C
254
+ });
255
+ return T.setStyle(w), T;
256
+ }
257
+ function createPointFeature(e, b) {
258
+ let x = createPoint(e);
259
+ return createFeature({
260
+ ...b,
261
+ geometry: x
262
+ });
263
+ }
264
+ function createLineStringFeature(e, b) {
265
+ let x = createLineString(e);
266
+ return createFeature({
267
+ ...b,
268
+ geometry: x
269
+ });
270
+ }
271
+ function createPolygonFeature(e, b) {
272
+ let x = createPolygon(e);
273
+ return createFeature({
274
+ ...b,
275
+ geometry: x
276
+ });
277
+ }
278
+ function createCircleFeature(e, b, x) {
279
+ let S = createCircle(e, b);
280
+ return createFeature({
281
+ ...x,
282
+ geometry: S
283
+ });
284
+ }
285
+ function createMultiPointFeature(e, b) {
286
+ let x = createMultiPoint(e);
287
+ return createFeature({
288
+ ...b,
289
+ geometry: x
290
+ });
291
+ }
292
+ function createMultiLineStringFeature(e, b) {
293
+ let x = createMultiLineString(e);
294
+ return createFeature({
295
+ ...b,
296
+ geometry: x
297
+ });
298
+ }
299
+ function createMultiPolygonFeature(e, b) {
300
+ let x = createMultiPolygon(e);
301
+ return createFeature({
302
+ ...b,
303
+ geometry: x
304
+ });
305
+ }
306
+ function getTianDiTuUrl(e) {
307
+ let { type: b = "img", projection: x = WebMercatorProjection, key: S } = e, C = e.url || "https://t{0-4}.tianditu.gov.cn", w = `&tk=${S}&SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}`;
308
+ return `${C}/${b}_${x === "EPSG:4326" ? "c" : x === "EPSG:3857" ? "w" : "c"}/wmts?LAYER=${b}${w}`;
309
+ }
310
+ function getTianDiTuLayer(e) {
311
+ let { zIndex: b, projection: x, className: S } = e;
312
+ return new Tile({
313
+ className: S,
314
+ source: new XYZ({
315
+ url: getTianDiTuUrl(e),
316
+ projection: x,
317
+ crossOrigin: "Anonymous"
318
+ }),
319
+ zIndex: b
320
+ });
321
+ }
322
+ function getBingLayer({ name: e, zIndex: b, key: x, className: S }) {
323
+ return new Tile({
324
+ className: S,
325
+ source: new BingMaps({
326
+ key: x,
327
+ imagerySet: e,
328
+ placeholderTiles: !1
329
+ }),
330
+ zIndex: b
331
+ });
332
+ }
333
+ function getOSMLayer(e) {
334
+ return new Tile({
335
+ className: e?.className,
336
+ source: new OSM({ crossOrigin: "Anonymous" }),
337
+ zIndex: e?.zIndex
338
+ });
339
+ }
340
+ function createVectorLayer(e) {
341
+ let { styleOptions: b,...x } = e || {}, S = b ? createStyle(b) : void 0, C = new VectorSource();
342
+ return {
343
+ source: C,
344
+ layer: new VectorLayer({
345
+ source: C,
346
+ ...x,
347
+ style: S || x.style
348
+ })
349
+ };
350
+ }
351
+ function wgs84ToMercator(e) {
352
+ return transform(e, EPSG_4326, EPSG_3857);
353
+ }
354
+ const EPSG_4326ToEPSG_3857 = wgs84ToMercator;
355
+ function mercatorToWgs84(e) {
356
+ return transform(e, EPSG_3857, EPSG_4326);
357
+ }
358
+ const EPSG_3857ToEPSG_4326 = mercatorToWgs84;
359
+ function wgs84ExtentToMercator(e) {
360
+ return transformExtent(e, EPSG_4326, EPSG_3857);
361
+ }
362
+ const EPSG_4326ExtentToEPSG_3857 = wgs84ExtentToMercator;
363
+ function mercatorExtentToWgs84(e) {
364
+ return transformExtent(e, EPSG_3857, EPSG_4326);
365
+ }
366
+ const EPSG_3857ExtentToEPSG_4326 = mercatorExtentToWgs84;
367
+ function createToolTipElement(e) {
368
+ let b = document.createElement("div");
369
+ return b.innerHTML = e, b.style.cursor = "pointer", b.style.userSelect = "none", b.style.backgroundColor = "red", b.style.color = "white", b.style.borderRadius = "5px", b.style.padding = "0 5px", b.style.fontSize = "12px", b.style.border = "2px solid white", b;
370
+ }
371
+ function useDrawLineString(b, x) {
372
+ let S = ref(!0), C = ref([]), E = computed(() => C.value.map((e) => e.getGeometry().getCoordinates())), D = new VectorSource(), A = x.styleOptions ? createStyle(x.styleOptions) : x?.style, j = new VectorLayer({
373
+ source: D,
374
+ style: A,
375
+ zIndex: x?.zIndex
376
+ });
377
+ b.addLayer(j);
378
+ let M = new Draw({
379
+ source: D,
380
+ style: (x.drawStyleOptions ? createStyle(x.drawStyleOptions) : x?.drawStyle) || A,
381
+ type: "LineString"
382
+ });
383
+ M.setActive(!1);
384
+ let N = new Modify({
385
+ source: D,
386
+ style: (x.modifyStyleOptions ? createStyle(x.modifyStyleOptions) : x?.modifyStyle) || A
387
+ }), F = /* @__PURE__ */ new Set();
388
+ b.addInteraction(M), onMounted(() => {
389
+ b.addInteraction(N);
390
+ }), D.on("addfeature", () => {
391
+ x.size && D.getFeatures().length >= x.size && M.setActive(!1);
392
+ }), D.on("removefeature", () => {
393
+ x.size && D.getFeatures().length < x.size && M.setActive(!0);
394
+ });
395
+ let L = () => {
396
+ F.forEach((e) => {
397
+ b.removeOverlay(e);
398
+ }), F.clear();
399
+ };
400
+ D.on("change", () => {
401
+ L(), D.getFeatures().forEach((e) => {
402
+ let S = e.getGeometry();
403
+ S.getCoordinates();
404
+ let C = getCenter(S.getExtent()), w = document.createElement("div");
405
+ x.deleteFeatureLabel ? render(x.deleteFeatureLabel, w) : w = createToolTipElement("删除线"), w.addEventListener("click", () => {
406
+ D.removeFeature(e);
407
+ });
408
+ let T = new Overlay({
409
+ position: C,
410
+ positioning: "center-center",
411
+ element: w
412
+ });
413
+ F.add(T), b.addOverlay(T);
414
+ let E = S.getCoordinates();
415
+ E.length < 3 || E.forEach((S, C) => {
416
+ let w = document.createElement("div");
417
+ x.deletePointLabel ? render(x.deletePointLabel, w) : w = createToolTipElement("删除点"), w.addEventListener("click", () => {
418
+ e.setGeometry(new LineString(E.filter((e, b) => b !== C)));
419
+ });
420
+ let T = new Overlay({
421
+ position: S,
422
+ positioning: "top-center",
423
+ offset: [0, -30],
424
+ element: w
425
+ });
426
+ F.add(T), b.addOverlay(T);
427
+ });
428
+ });
429
+ }), M.on("change:active", () => {
430
+ S.value = M.getActive();
431
+ }), D.on("change", () => {
432
+ C.value = D.getFeatures();
433
+ });
434
+ let R = () => {
435
+ L(), b.removeLayer(j), b.removeInteraction(M), b.removeInteraction(N);
436
+ }, z = () => {
437
+ x.size && C.value.length >= x.size || M.setActive(!0);
438
+ }, B = () => {
439
+ M.setActive(!1);
440
+ }, V = (e) => {
441
+ D.clear(), e.forEach((e) => {
442
+ if (e.length < 2) return;
443
+ let b = new Feature({ geometry: new LineString(e) });
444
+ D.addFeature(b);
445
+ });
446
+ }, H = () => {
447
+ V(x.defaultCoordinates || []);
448
+ };
449
+ return H(), onUnmounted(() => {
450
+ R();
451
+ }), {
452
+ inDraw: S,
453
+ start: z,
454
+ stop: B,
455
+ clear: () => {
456
+ D.clear(), B();
457
+ },
458
+ setFeatures: V,
459
+ reset: H,
460
+ features: C,
461
+ coordinates: E,
462
+ destroy: R
463
+ };
464
+ }
465
+ function useDrawPolygon(b, x) {
466
+ let S = ref(!0), C = ref([]), E = computed(() => C.value.map((e) => e.getGeometry().getCoordinates())), D = x.styleOptions ? createStyle(x.styleOptions) : x?.style, A = new VectorSource(), j = new VectorLayer({
467
+ source: A,
468
+ style: D,
469
+ zIndex: x?.zIndex
470
+ });
471
+ b.addLayer(j);
472
+ let M = new Draw({
473
+ source: A,
474
+ style: (x.drawStyleOptions ? createStyle(x.drawStyleOptions) : x?.drawStyle) || D,
475
+ type: "Polygon"
476
+ });
477
+ M.setActive(!1);
478
+ let N = new Modify({
479
+ source: A,
480
+ style: (x.modifyStyleOptions ? createStyle(x.modifyStyleOptions) : x?.modifyStyle) || D
481
+ }), F = /* @__PURE__ */ new Set();
482
+ b.addInteraction(M), onMounted(() => {
483
+ b.addInteraction(N);
484
+ }), A.on("addfeature", () => {
485
+ x.size && A.getFeatures().length >= x.size && M.setActive(!1);
486
+ }), A.on("removefeature", () => {
487
+ x.size && A.getFeatures().length < x.size && M.setActive(!0);
488
+ });
489
+ let L = () => {
490
+ F.forEach((e) => {
491
+ b.removeOverlay(e);
492
+ }), F.clear();
493
+ };
494
+ A.on("change", () => {
495
+ L(), A.getFeatures().forEach((e) => {
496
+ let S = e.getGeometry(), C = getCenter(S.getExtent()), w = document.createElement("div");
497
+ x.deleteFeatureLabel ? render(x.deleteFeatureLabel, w) : w = createToolTipElement("删除区域"), w.addEventListener("click", () => {
498
+ A.removeFeature(e);
499
+ });
500
+ let T = new Overlay({
501
+ position: C,
502
+ positioning: "center-center",
503
+ element: w
504
+ });
505
+ F.add(T), b.addOverlay(T);
506
+ let E = S.getCoordinates()[0];
507
+ E.length < 3 || E.forEach((S, C) => {
508
+ let w = document.createElement("div");
509
+ x.deletePointLabel ? render(x.deletePointLabel, w) : w = createToolTipElement("删除点"), w.addEventListener("click", () => {
510
+ e.setGeometry(new Polygon([E.filter((e, b) => b !== C)]));
511
+ });
512
+ let T = new Overlay({
513
+ position: S,
514
+ positioning: "top-center",
515
+ offset: [0, -30],
516
+ element: w
517
+ });
518
+ F.add(T), b.addOverlay(T);
519
+ });
520
+ });
521
+ }), M.on("change:active", () => {
522
+ S.value = M.getActive();
523
+ }), A.on("change", () => {
524
+ C.value = A.getFeatures();
525
+ });
526
+ let R = () => {
527
+ L(), b.removeLayer(j), b.removeInteraction(M), b.removeInteraction(N);
528
+ }, z = () => {
529
+ x.size && C.value.length >= x.size || M.setActive(!0);
530
+ }, B = () => {
531
+ M.setActive(!1);
532
+ }, V = (e) => {
533
+ A.clear(), e?.forEach((e) => {
534
+ e.forEach((e) => {
535
+ if (e.length < 2) return;
536
+ e[0] !== e[e.length - 1] && e.push(e[0]);
537
+ let b = new Feature({ geometry: new Polygon([e]) });
538
+ A.addFeature(b);
539
+ });
540
+ });
541
+ }, H = () => {
542
+ V(x.defaultCoordinates);
543
+ };
544
+ return H(), onUnmounted(() => {
545
+ R();
546
+ }), {
547
+ inDraw: S,
548
+ start: z,
549
+ stop: B,
550
+ clear: () => {
551
+ A.clear(), B();
552
+ },
553
+ setFeatures: V,
554
+ reset: H,
555
+ features: C,
556
+ coordinates: E,
557
+ destroy: R
558
+ };
559
+ }
560
+ function useGraticule(e) {
561
+ let b = ref(e.defaultShow || !1), { strokeStyleOption: x, strokeStyle: S, labelStyleOption: C, latLabelStyleOption: w, lonLabelStyleOption: T, latLabelStyle: E, lonLabelStyle: D,...k } = e.graticuleOptions || {}, A = x ? new Stroke(x) : S, M = C ? createTextStyle(C) : void 0, P = (w ? createTextStyle(w) : E) || M, F = (T ? createTextStyle(T) : D) || M, I = new Graticule({
562
+ ...k,
563
+ strokeStyle: A,
564
+ latLabelStyle: P,
565
+ lonLabelStyle: F
566
+ });
567
+ return watch(b, (b) => {
568
+ if (I.setMap(null), b) {
569
+ let b = toValue(e.olMap);
570
+ b && I.setMap(b);
571
+ }
572
+ }, {
573
+ immediate: !0,
574
+ deep: !0
575
+ }), { showGraticule: b };
576
+ }
577
+ function usePointermove(b, x) {
578
+ let S = ref(!1), w = ref({
579
+ x: 0,
580
+ y: 0
581
+ }), T = ref(), E = ref(), D = ref({
582
+ x: 0,
583
+ y: 0
584
+ }), k = ref(), A = ref(), M = computed(() => ({
585
+ x: w.value.x + D.value.x,
586
+ y: w.value.y + D.value.y
587
+ })), P, F = "";
588
+ function I(e) {
589
+ let b = toValue(x).filter((b) => {
590
+ let x = b.visible;
591
+ return typeof x == "function" ? x(e) : x ?? !0;
592
+ });
593
+ return b.length === 0 ? null : b.sort((e, b) => (b.priority ?? 0) - (e.priority ?? 0))[0];
594
+ }
595
+ function L(e) {
596
+ if (!P) return;
597
+ let b = P.getEventCoordinate(e);
598
+ k.value = b;
599
+ let x = P.getEventPixel(e), C, O;
600
+ if (P.forEachFeatureAtPixel(x, (e, b) => (C = e, O = b, !0)), !C) {
601
+ R();
602
+ return;
603
+ }
604
+ T.value = C;
605
+ let j = {
606
+ map: P,
607
+ position: {
608
+ x: e.clientX,
609
+ y: e.clientY
610
+ },
611
+ coordinate: b,
612
+ feature: C,
613
+ layer: O
614
+ }, M = I(j);
615
+ if (M) {
616
+ let { content: e, cursor: b, visible: x, fixedFeatureCenter: S, offset: C, priority: w,...T } = M;
617
+ A.value = { ...T };
618
+ }
619
+ if (!M) {
620
+ R();
621
+ return;
622
+ }
623
+ D.value = {
624
+ x: M.offset?.x ?? 0,
625
+ y: M.offset?.y ?? 0
626
+ };
627
+ let N = M.fixedFeatureCenter ?? !0, L = C.getGeometry();
628
+ if (N && L) {
629
+ let e = getCenter(L.getExtent()), b = P.getPixelFromCoordinate(e), { top: x, left: S } = P.getViewport().getBoundingClientRect();
630
+ w.value.x = b[0] + S, w.value.y = b[1] + x;
631
+ } else w.value = {
632
+ x: e.clientX,
633
+ y: e.clientY
634
+ };
635
+ let z = M.content;
636
+ E.value = typeof z == "function" ? () => z(j) : z;
637
+ let B = M.cursor, V = typeof B == "function" ? B(j) : B;
638
+ if (V && P) {
639
+ let e = P.getViewport();
640
+ F ||= e.style.cursor, e.style.cursor = V;
641
+ }
642
+ S.value = !0;
643
+ }
644
+ function R() {
645
+ if (S.value = !1, T.value = void 0, P && F !== void 0) {
646
+ let e = P.getViewport();
647
+ e.style.cursor = F, F = "";
648
+ }
649
+ }
650
+ function z(e) {
651
+ if (!e) return;
652
+ let b = e.getViewport();
653
+ b.addEventListener("pointermove", L), b.addEventListener("pointerout", R);
654
+ }
655
+ function B(e) {
656
+ if (!e) return;
657
+ let b = e.getViewport();
658
+ b.removeEventListener("pointermove", L), b.removeEventListener("pointerout", R);
659
+ }
660
+ return watch(() => toValue(b), (e, b) => {
661
+ b !== e && (B(b), z(e), P = e);
662
+ }, { immediate: !0 }), onBeforeUnmount(() => {
663
+ B(P);
664
+ }), {
665
+ visible: computed(() => S.value),
666
+ position: computed(() => M.value),
667
+ originalPosition: computed(() => w.value),
668
+ feature: computed(() => T.value),
669
+ content: computed(() => E.value),
670
+ coordinate: computed(() => k.value),
671
+ option: computed(() => A.value),
672
+ hide: R
673
+ };
674
+ }
675
+ function useSwitchBaseLayer(e) {
676
+ let b = ref(e.defaultLayerName || Object.keys(e.layers)[0]);
677
+ return Object.values(e.layers).forEach((b) => {
678
+ b.forEach((b) => {
679
+ e.olMap.addLayer(b);
680
+ });
681
+ }), watch(b, () => {
682
+ Object.entries(e.layers).forEach(([e, x]) => {
683
+ let S = e === b.value;
684
+ x.forEach((e) => {
685
+ e.setVisible(S);
686
+ });
687
+ });
688
+ }, { immediate: !0 }), { visibleLayerName: b };
689
+ }
690
+ export { EPSG_3857, EPSG_3857ExtentToEPSG_4326, EPSG_3857ToEPSG_4326, EPSG_4326, EPSG_4326ExtentToEPSG_3857, EPSG_4326ToEPSG_3857, ONE_NM, ol_map_default as OlMap, WGS84Projection, WebMercatorProjection, createCircle, createCircleFeature, createCircleStyle, createFeature, createLineString, createLineStringFeature, createMultiLineString, createMultiLineStringFeature, createMultiPoint, createMultiPointFeature, createMultiPolygon, createMultiPolygonFeature, createPoint, createPointFeature, createPolygon, createPolygonFeature, createStyle, createTextStyle, createVectorLayer, getBingLayer, getOSMLayer, getTianDiTuLayer, getTianDiTuUrl, kmToNauticalMiles, mercatorExtentToWgs84, mercatorToWgs84, nauticalMilesToKm, olMapInjectionKey, useContextmenu, useDrawLineString, useDrawPolygon, useGraticule, useOlMap, usePointermove, useSwitchBaseLayer, wgs84ExtentToMercator, wgs84ToMercator };