@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
@@ -0,0 +1,3 @@
1
+ import { olMapInjectionKey, useOlMap } from "./ol-map/props.mjs";
2
+ import ol_map_default from "./ol-map/index.mjs";
3
+ import "./ol-map/index2.mjs";
@@ -0,0 +1,3 @@
1
+ import index_vue_vue_type_script_setup_true_lang_default from "./index.vue_vue_type_script_setup_true_lang.mjs";
2
+ var ol_map_default = index_vue_vue_type_script_setup_true_lang_default;
3
+ export { ol_map_default as default };
@@ -0,0 +1,114 @@
1
+ import { olMapInjectionKey } from "./props.mjs";
2
+ import { createElementBlock, defineComponent, openBlock, provide, ref, renderSlot, unref, watch } from "vue";
3
+ import { Map, View } from "ol";
4
+ import { Attribution, FullScreen, OverviewMap, Rotate, ScaleLine, Zoom } from "ol/control";
5
+ import { DoubleClickZoom, DragPan, DragRotate, KeyboardPan, KeyboardZoom, MouseWheelZoom, PinchRotate, PinchZoom } from "ol/interaction";
6
+ var index_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
7
+ __name: "index",
8
+ props: {
9
+ olMap: { default: () => new Map() },
10
+ center: { default: () => [0, 0] },
11
+ zoom: { default: 2 },
12
+ minZoom: { default: 2 },
13
+ maxZoom: { default: 18 },
14
+ constrainResolution: {
15
+ type: Boolean,
16
+ default: !0
17
+ },
18
+ projection: {},
19
+ extent: {},
20
+ showZoom: {
21
+ type: Boolean,
22
+ default: !1
23
+ },
24
+ showAttribution: {
25
+ type: Boolean,
26
+ default: !1
27
+ },
28
+ showRotate: {
29
+ type: Boolean,
30
+ default: !1
31
+ },
32
+ showFullScreen: {
33
+ type: Boolean,
34
+ default: !1
35
+ },
36
+ showOverview: {
37
+ type: Boolean,
38
+ default: !1
39
+ },
40
+ showScale: {
41
+ type: Boolean,
42
+ default: !1
43
+ },
44
+ dragPan: {
45
+ type: Boolean,
46
+ default: !0
47
+ },
48
+ mouseWheelZoom: {
49
+ type: Boolean,
50
+ default: !0
51
+ },
52
+ doubleClickZoom: {
53
+ type: Boolean,
54
+ default: !1
55
+ },
56
+ pinchRotate: { type: Boolean },
57
+ pinchZoom: { type: Boolean },
58
+ altShiftDragRotate: { type: Boolean }
59
+ },
60
+ setup(C, { expose: w }) {
61
+ let T = C, E = ref(), D = T.olMap, O = new View({
62
+ projection: T.projection,
63
+ extent: T.extent
64
+ });
65
+ D.setView(O), watch(() => T.zoom, (e) => {
66
+ O.setZoom(e);
67
+ }, { immediate: !0 }), watch(() => T.center, (e) => {
68
+ O.setCenter(e);
69
+ }, { immediate: !0 }), watch(() => T.constrainResolution, (e) => {
70
+ O.setConstrainResolution(e);
71
+ }, { immediate: !0 }), watch(() => T.minZoom, (e) => {
72
+ e && O.setMinZoom(e);
73
+ }, { immediate: !0 }), watch(() => T.maxZoom, (e) => {
74
+ e && O.setMaxZoom(e);
75
+ }, { immediate: !0 }), watch(E, (e) => {
76
+ e && D.setTarget(e);
77
+ }), w({ olMap: D }), provide(olMapInjectionKey, D);
78
+ let k = D.getControls().getArray(), A = k.find((e) => e instanceof Zoom) || new Zoom(), j = k.find((e) => e instanceof Attribution) || new Attribution(), M = k.find((e) => e instanceof Rotate) || new Rotate(), N = k.find((e) => e instanceof FullScreen) || new FullScreen(), P = k.find((e) => e instanceof OverviewMap) || new OverviewMap(), F = k.find((e) => e instanceof ScaleLine) || new ScaleLine();
79
+ watch(() => T.showZoom, (e) => {
80
+ A.setMap(e ? D : null);
81
+ }, { immediate: !0 }), watch(() => T.showAttribution, (e) => {
82
+ j.setMap(e ? D : null);
83
+ }, { immediate: !0 }), watch(() => T.showRotate, (e) => {
84
+ M.setMap(e ? D : null);
85
+ }, { immediate: !0 }), watch(() => T.showFullScreen, (e) => {
86
+ N.setMap(e ? D : null);
87
+ }, { immediate: !0 }), watch(() => T.showOverview, (e) => {
88
+ P.setMap(e ? D : null);
89
+ }, { immediate: !0 }), watch(() => T.showScale, (e) => {
90
+ F.setMap(e ? D : null);
91
+ }, { immediate: !0 });
92
+ let I = D.getInteractions().getArray(), L = I.find((e) => e instanceof DragPan) || new DragPan(), R = I.find((e) => e instanceof MouseWheelZoom) || new MouseWheelZoom(), z = I.find((e) => e instanceof DoubleClickZoom) || new DoubleClickZoom(), B = I.find((e) => e instanceof PinchRotate) || new PinchRotate(), V = I.find((e) => e instanceof PinchZoom) || new PinchZoom(), H = I.find((e) => e instanceof DragRotate) || new DragRotate(), U = I.find((e) => e instanceof KeyboardPan) || new KeyboardPan(), W = I.find((e) => e instanceof KeyboardZoom) || new KeyboardZoom();
93
+ return D.removeInteraction(L), D.addInteraction(L), D.removeInteraction(R), D.addInteraction(R), D.removeInteraction(z), D.addInteraction(z), D.removeInteraction(B), D.addInteraction(B), D.removeInteraction(V), D.addInteraction(V), D.removeInteraction(H), D.addInteraction(H), D.removeInteraction(U), D.removeInteraction(W), watch(() => T.dragPan, (e) => {
94
+ L.setActive(e);
95
+ }, { immediate: !0 }), watch(() => T.mouseWheelZoom, (e) => {
96
+ R.setActive(e);
97
+ }, { immediate: !0 }), watch(() => T.doubleClickZoom, (e) => {
98
+ z.setActive(e);
99
+ }, { immediate: !0 }), watch(() => T.pinchRotate, (e) => {
100
+ B.setActive(e);
101
+ }, { immediate: !0 }), watch(() => T.pinchZoom, (e) => {
102
+ V.setActive(e);
103
+ }, { immediate: !0 }), watch(() => T.altShiftDragRotate, (e) => {
104
+ H.setActive(e);
105
+ }, { immediate: !0 }), (e, C) => (openBlock(), createElementBlock("div", {
106
+ ref_key: "mapRef",
107
+ ref: E
108
+ }, [renderSlot(e.$slots, "default", {
109
+ olMap: unref(D),
110
+ mapRef: E.value
111
+ })], 512));
112
+ }
113
+ });
114
+ export { index_vue_vue_type_script_setup_true_lang_default as default };
@@ -0,0 +1,2 @@
1
+ import { olMapInjectionKey, useOlMap } from "./props.mjs";
2
+ import ol_map_default from "./index.mjs";
@@ -1,9 +1,6 @@
1
- import { inject as o } from "vue";
2
- const n = Symbol("olMapInjectionKey");
3
- function t() {
4
- return o(n);
1
+ import { inject } from "vue";
2
+ const olMapInjectionKey = Symbol("olMapInjectionKey");
3
+ function useOlMap() {
4
+ return inject(olMapInjectionKey);
5
5
  }
6
- export {
7
- n as olMapInjectionKey,
8
- t as useOlMap
9
- };
6
+ export { olMapInjectionKey, useOlMap };
@@ -1,7 +1,5 @@
1
- function o(t) {
2
- const e = document.createElement("div");
3
- 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;
1
+ function createToolTipElement(e) {
2
+ let t = document.createElement("div");
3
+ return t.innerHTML = e, t.style.cursor = "pointer", t.style.userSelect = "none", t.style.backgroundColor = "red", t.style.color = "white", t.style.borderRadius = "5px", t.style.padding = "0 5px", t.style.fontSize = "12px", t.style.border = "2px solid white", t;
4
4
  }
5
- export {
6
- o as createToolTipElement
7
- };
5
+ export { createToolTipElement };
@@ -0,0 +1,6 @@
1
+ import { useContextmenu } from "./useContextmenu/index.mjs";
2
+ import { useDrawLineString } from "./useDrawLineString/index.mjs";
3
+ import { useDrawPolygon } from "./useDrawPolygon/index.mjs";
4
+ import { useGraticule } from "./useGraticule/index.mjs";
5
+ import { usePointermove } from "./usePointermove/index.mjs";
6
+ import { useSwitchBaseLayer } from "./useSwitchBaseLayer/index.mjs";
@@ -1,77 +1,71 @@
1
- import { ref as u, watch as A, toValue as y, onBeforeUnmount as C, computed as l } from "vue";
2
- function P(g, L) {
3
- const a = u(!1), d = u({ x: 0, y: 0 }), v = u(), b = u([]), h = u();
4
- let i;
5
- function p(t, n) {
6
- const s = [];
7
- return t.filter((e) => {
8
- const o = e.visible;
9
- return typeof o == "function" ? o(n) : o ?? !0;
10
- }).filter((e) => !e.children || e.children.length > 0).sort((e, o) => (e.order ?? 0) - (o.order ?? 0)).forEach((e) => {
11
- const o = e.icon, r = e.label;
12
- s.push({
13
- ...e,
14
- children: e.children ? p(e.children, n) : void 0,
15
- visible: !0,
16
- action: () => {
17
- var f;
18
- (f = e.action) == null || f.call(e, n), c();
19
- },
20
- icon: typeof o == "function" ? () => o(n) : o,
21
- label: typeof r == "function" ? () => r(n) : r,
22
- disabled: typeof e.disabled == "function" ? e.disabled(n) : e.disabled ?? !1
23
- });
24
- }), s;
25
- }
26
- function E(t) {
27
- if (t.preventDefault(), !i)
28
- return;
29
- const n = i.getEventCoordinate(t);
30
- h.value = n;
31
- const s = i.getEventPixel(t);
32
- let e, o;
33
- i.forEachFeatureAtPixel(s, (k, w) => (e = k, o = w, !0)), v.value = e;
34
- const [r, f] = [t.clientX, t.clientY];
35
- d.value = { x: r, y: f }, b.value = p(y(L), {
36
- map: i,
37
- position: { ...d.value },
38
- coordinate: n,
39
- feature: e,
40
- layer: o
41
- }), a.value = !0;
42
- }
43
- function c() {
44
- a.value = !1;
45
- }
46
- function V(t) {
47
- if (!t)
48
- return;
49
- const n = t.getViewport();
50
- n.addEventListener("contextmenu", E), n.addEventListener("click", c);
51
- }
52
- function x(t) {
53
- if (!t)
54
- return;
55
- const n = t.getViewport();
56
- n.removeEventListener("contextmenu", E), n.removeEventListener("click", c);
57
- }
58
- return A(
59
- () => y(g),
60
- (t, n) => {
61
- n !== t && (x(n), V(t), i = t);
62
- },
63
- { immediate: !0 }
64
- ), C(() => {
65
- x(i);
66
- }), {
67
- visible: l(() => a.value),
68
- position: l(() => d.value),
69
- feature: l(() => v.value),
70
- options: l(() => b.value),
71
- coordinate: l(() => h.value),
72
- hide: c
73
- };
1
+ import { computed, onBeforeUnmount, ref, toValue, watch } from "vue";
2
+ function useContextmenu(a, o) {
3
+ let s = ref(!1), c = ref({
4
+ x: 0,
5
+ y: 0
6
+ }), l = ref(), u = ref([]), d = ref(), f;
7
+ function p(e, t) {
8
+ let n = [];
9
+ return e.filter((e) => {
10
+ let n = e.visible;
11
+ return typeof n == "function" ? n(t) : n ?? !0;
12
+ }).filter((e) => !e.children || e.children.length > 0).sort((e, t) => (e.order ?? 0) - (t.order ?? 0)).forEach((e) => {
13
+ let r = e.icon, i = e.label;
14
+ n.push({
15
+ ...e,
16
+ children: e.children ? p(e.children, t) : void 0,
17
+ visible: !0,
18
+ action: () => {
19
+ e.action?.(t), h();
20
+ },
21
+ icon: typeof r == "function" ? () => r(t) : r,
22
+ label: typeof i == "function" ? () => i(t) : i,
23
+ disabled: typeof e.disabled == "function" ? e.disabled(t) : e.disabled ?? !1
24
+ });
25
+ }), n;
26
+ }
27
+ function m(e) {
28
+ if (e.preventDefault(), !f) return;
29
+ let t = f.getEventCoordinate(e);
30
+ d.value = t;
31
+ let n = f.getEventPixel(e), i, a;
32
+ f.forEachFeatureAtPixel(n, (e, t) => (i = e, a = t, !0)), l.value = i;
33
+ let [m, h] = [e.clientX, e.clientY];
34
+ c.value = {
35
+ x: m,
36
+ y: h
37
+ }, u.value = p(toValue(o), {
38
+ map: f,
39
+ position: { ...c.value },
40
+ coordinate: t,
41
+ feature: i,
42
+ layer: a
43
+ }), s.value = !0;
44
+ }
45
+ function h() {
46
+ s.value = !1;
47
+ }
48
+ function g(e) {
49
+ if (!e) return;
50
+ let t = e.getViewport();
51
+ t.addEventListener("contextmenu", m), t.addEventListener("click", h);
52
+ }
53
+ function _(e) {
54
+ if (!e) return;
55
+ let t = e.getViewport();
56
+ t.removeEventListener("contextmenu", m), t.removeEventListener("click", h);
57
+ }
58
+ return watch(() => toValue(a), (e, t) => {
59
+ t !== e && (_(t), g(e), f = e);
60
+ }, { immediate: !0 }), onBeforeUnmount(() => {
61
+ _(f);
62
+ }), {
63
+ visible: computed(() => s.value),
64
+ position: computed(() => c.value),
65
+ feature: computed(() => l.value),
66
+ options: computed(() => u.value),
67
+ coordinate: computed(() => d.value),
68
+ hide: h
69
+ };
74
70
  }
75
- export {
76
- P as useContextmenu
77
- };
71
+ export { useContextmenu };
@@ -1,113 +1,105 @@
1
- import { Overlay as z, Feature as W } from "ol";
2
- import { LineString as x } from "ol/geom";
3
- import { Draw as _, Modify as j } from "ol/interaction";
4
- import q from "ol/layer/Vector";
5
- import B from "ol/source/Vector";
6
- import { ref as A, computed as H, onMounted as J, render as I, onUnmounted as K } from "vue";
7
- import { getExtentCenter as N } from "../../utils/calculate/index.mjs";
8
- import { createStyle as y } from "../../utils/style/index.mjs";
9
- import "ol/layer";
10
- import "ol/source";
11
- import { mercatorExtentToWgs84 as Q, wgs84ToMercator as R } from "../../utils/projection/index.mjs";
12
- import { createToolTipElement as b } from "../common/index.mjs";
13
- function de(r, e) {
14
- const u = A(!0), l = A([]), C = H(() => l.value.map((a) => a.getGeometry().getCoordinates())), t = new B(), o = e.styleOptions ? y(e.styleOptions) : e == null ? void 0 : e.style, v = new q({
15
- source: t,
16
- style: o,
17
- zIndex: e == null ? void 0 : e.zIndex
18
- });
19
- r.addLayer(v);
20
- const T = e.drawStyleOptions ? y(e.drawStyleOptions) : e == null ? void 0 : e.drawStyle, n = new _({
21
- source: t,
22
- style: T || o,
23
- type: "LineString"
24
- });
25
- n.setActive(!1);
26
- const D = e.modifyStyleOptions ? y(e.modifyStyleOptions) : e == null ? void 0 : e.modifyStyle, g = new j({
27
- source: t,
28
- style: D || o
29
- }), d = /* @__PURE__ */ new Set();
30
- r.addInteraction(n), J(() => {
31
- r.addInteraction(g);
32
- }), t.on("addfeature", () => {
33
- e.size && t.getFeatures().length >= e.size && n.setActive(!1);
34
- }), t.on("removefeature", () => {
35
- e.size && t.getFeatures().length < e.size && n.setActive(!0);
36
- });
37
- const w = () => {
38
- d.forEach((a) => {
39
- r.removeOverlay(a);
40
- }), d.clear();
41
- };
42
- t.on("change", () => {
43
- w(), t.getFeatures().forEach((a) => {
44
- const c = a.getGeometry(), s = N(Q(c.getExtent()));
45
- let m = document.createElement("div");
46
- e.deleteFeatureLabel ? I(e.deleteFeatureLabel, m) : m = b("删除线"), m.addEventListener("click", () => {
47
- t.removeFeature(a);
48
- });
49
- const O = new z({
50
- position: R(s),
51
- positioning: "center-center",
52
- element: m
53
- });
54
- d.add(O), r.addOverlay(O);
55
- const f = c.getCoordinates();
56
- f.length < 3 || f.forEach((P, V) => {
57
- let i = document.createElement("div");
58
- e.deletePointLabel ? I(e.deletePointLabel, i) : i = b("删除点"), i.addEventListener("click", () => {
59
- a.setGeometry(new x(f.filter((X, U) => U !== V)));
60
- });
61
- const F = new z({
62
- position: P,
63
- positioning: "top-center",
64
- offset: [0, -30],
65
- element: i
66
- });
67
- d.add(F), r.addOverlay(F);
68
- });
69
- });
70
- }), n.on("change:active", () => {
71
- u.value = n.getActive();
72
- }), t.on("change", () => {
73
- l.value = t.getFeatures();
74
- });
75
- const S = () => {
76
- w(), r.removeLayer(v), r.removeInteraction(n), r.removeInteraction(g);
77
- }, G = () => {
78
- e.size && l.value.length >= e.size || n.setActive(!0);
79
- }, h = () => {
80
- n.setActive(!1);
81
- }, E = (a) => {
82
- t.clear(), a.forEach((c) => {
83
- if (c.length < 2)
84
- return;
85
- const s = new W({
86
- geometry: new x(c)
87
- });
88
- t.addFeature(s);
89
- });
90
- }, L = () => {
91
- E(e.defaultCoordinates || []);
92
- };
93
- L();
94
- const k = () => {
95
- t.clear(), h();
96
- };
97
- return K(() => {
98
- S();
99
- }), {
100
- inDraw: u,
101
- start: G,
102
- stop: h,
103
- clear: k,
104
- setFeatures: E,
105
- reset: L,
106
- features: l,
107
- coordinates: C,
108
- destroy: S
109
- };
1
+ import { createStyle } from "../../utils/style/index.mjs";
2
+ import "../../utils/index.mjs";
3
+ import { createToolTipElement } from "../common/index.mjs";
4
+ import { computed, onMounted, onUnmounted, ref, render } from "vue";
5
+ import { Feature, Overlay } from "ol";
6
+ import { Draw, Modify } from "ol/interaction";
7
+ import { getCenter } from "ol/extent";
8
+ import { LineString } from "ol/geom";
9
+ import VectorLayer from "ol/layer/Vector";
10
+ import VectorSource from "ol/source/Vector";
11
+ function useDrawLineString(h, g) {
12
+ let _ = ref(!0), v = ref([]), y = computed(() => v.value.map((e) => e.getGeometry().getCoordinates())), b = new VectorSource(), x = g.styleOptions ? createStyle(g.styleOptions) : g?.style, S = new VectorLayer({
13
+ source: b,
14
+ style: x,
15
+ zIndex: g?.zIndex
16
+ });
17
+ h.addLayer(S);
18
+ let C = new Draw({
19
+ source: b,
20
+ style: (g.drawStyleOptions ? createStyle(g.drawStyleOptions) : g?.drawStyle) || x,
21
+ type: "LineString"
22
+ });
23
+ C.setActive(!1);
24
+ let w = new Modify({
25
+ source: b,
26
+ style: (g.modifyStyleOptions ? createStyle(g.modifyStyleOptions) : g?.modifyStyle) || x
27
+ }), T = /* @__PURE__ */ new Set();
28
+ h.addInteraction(C), onMounted(() => {
29
+ h.addInteraction(w);
30
+ }), b.on("addfeature", () => {
31
+ g.size && b.getFeatures().length >= g.size && C.setActive(!1);
32
+ }), b.on("removefeature", () => {
33
+ g.size && b.getFeatures().length < g.size && C.setActive(!0);
34
+ });
35
+ let E = () => {
36
+ T.forEach((e) => {
37
+ h.removeOverlay(e);
38
+ }), T.clear();
39
+ };
40
+ b.on("change", () => {
41
+ E(), b.getFeatures().forEach((e) => {
42
+ let u = e.getGeometry();
43
+ u.getCoordinates();
44
+ let d = getCenter(u.getExtent()), f = document.createElement("div");
45
+ g.deleteFeatureLabel ? render(g.deleteFeatureLabel, f) : f = createToolTipElement("删除线"), f.addEventListener("click", () => {
46
+ b.removeFeature(e);
47
+ });
48
+ let p = new Overlay({
49
+ position: d,
50
+ positioning: "center-center",
51
+ element: f
52
+ });
53
+ T.add(p), h.addOverlay(p);
54
+ let m = u.getCoordinates();
55
+ m.length < 3 || m.forEach((u, d) => {
56
+ let f = document.createElement("div");
57
+ g.deletePointLabel ? render(g.deletePointLabel, f) : f = createToolTipElement("删除点"), f.addEventListener("click", () => {
58
+ e.setGeometry(new LineString(m.filter((e, l) => l !== d)));
59
+ });
60
+ let p = new Overlay({
61
+ position: u,
62
+ positioning: "top-center",
63
+ offset: [0, -30],
64
+ element: f
65
+ });
66
+ T.add(p), h.addOverlay(p);
67
+ });
68
+ });
69
+ }), C.on("change:active", () => {
70
+ _.value = C.getActive();
71
+ }), b.on("change", () => {
72
+ v.value = b.getFeatures();
73
+ });
74
+ let D = () => {
75
+ E(), h.removeLayer(S), h.removeInteraction(C), h.removeInteraction(w);
76
+ }, O = () => {
77
+ g.size && v.value.length >= g.size || C.setActive(!0);
78
+ }, k = () => {
79
+ C.setActive(!1);
80
+ }, A = (e) => {
81
+ b.clear(), e.forEach((e) => {
82
+ if (e.length < 2) return;
83
+ let l = new Feature({ geometry: new LineString(e) });
84
+ b.addFeature(l);
85
+ });
86
+ }, j = () => {
87
+ A(g.defaultCoordinates || []);
88
+ };
89
+ return j(), onUnmounted(() => {
90
+ D();
91
+ }), {
92
+ inDraw: _,
93
+ start: O,
94
+ stop: k,
95
+ clear: () => {
96
+ b.clear(), k();
97
+ },
98
+ setFeatures: A,
99
+ reset: j,
100
+ features: v,
101
+ coordinates: y,
102
+ destroy: D
103
+ };
110
104
  }
111
- export {
112
- de as useDrawLineString
113
- };
105
+ export { useDrawLineString };