@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.
- package/CHANGELOG.md +8 -0
- package/dist/index.js +689 -816
- package/es/components/index.mjs +3 -0
- package/es/components/ol-map/index.mjs +3 -0
- package/es/components/ol-map/index.vue_vue_type_script_setup_true_lang.mjs +114 -0
- package/es/components/ol-map/index2.mjs +2 -0
- package/es/components/ol-map/props.mjs +5 -8
- package/es/composables/common/index.mjs +4 -6
- package/es/composables/index.mjs +6 -0
- package/es/composables/useContextmenu/index.mjs +70 -76
- package/es/composables/useDrawLineString/index.mjs +104 -112
- package/es/composables/useDrawPolygon/index.mjs +105 -115
- package/es/composables/useGraticule/index.mjs +22 -36
- package/es/composables/usePointermove/index.mjs +100 -99
- package/es/composables/useSwitchBaseLayer/index.mjs +16 -24
- package/es/constants/distance.mjs +2 -4
- package/es/constants/projection.mjs +2 -7
- package/es/index.mjs +19 -76
- package/es/utils/distance/index.mjs +6 -9
- package/es/utils/feature/index.mjs +66 -82
- package/es/utils/index.d.ts +0 -3
- package/es/utils/index.mjs +5 -0
- package/es/utils/layer/index.d.ts +1 -1
- package/es/utils/layer/index.mjs +47 -60
- package/es/utils/projection/index.mjs +15 -24
- package/es/utils/style/index.mjs +27 -31
- package/lib/_virtual/rolldown_runtime.js +1 -0
- package/lib/components/index.js +1 -0
- package/lib/components/ol-map/index.js +1 -0
- package/lib/components/ol-map/index.vue_vue_type_script_setup_true_lang.js +1 -0
- package/lib/components/ol-map/index2.js +1 -0
- package/lib/components/ol-map/props.js +1 -1
- package/lib/composables/common/index.js +1 -1
- package/lib/composables/index.js +1 -0
- package/lib/composables/useContextmenu/index.js +1 -1
- package/lib/composables/useDrawLineString/index.js +1 -1
- package/lib/composables/useDrawPolygon/index.js +1 -1
- package/lib/composables/useGraticule/index.js +1 -1
- package/lib/composables/usePointermove/index.js +1 -1
- package/lib/composables/useSwitchBaseLayer/index.js +1 -1
- package/lib/constants/distance.js +1 -1
- package/lib/constants/projection.js +1 -1
- package/lib/index.js +1 -1
- package/lib/utils/distance/index.js +1 -1
- package/lib/utils/feature/index.js +1 -1
- package/lib/utils/index.d.ts +0 -3
- package/lib/utils/index.js +1 -0
- package/lib/utils/layer/index.d.ts +1 -1
- package/lib/utils/layer/index.js +1 -1
- package/lib/utils/projection/index.js +1 -1
- package/lib/utils/style/index.js +1 -1
- package/package.json +4 -11
- package/es/components/ol-map/index.vue.mjs +0 -124
- package/es/components/ol-map/index.vue2.mjs +0 -4
- package/es/utils/calculate/index.d.ts +0 -24
- package/es/utils/calculate/index.mjs +0 -29
- package/es/utils/calculate/index.test.d.ts +0 -1
- package/es/utils/format/index.d.ts +0 -4
- package/es/utils/format/index.mjs +0 -10
- package/es/utils/realCircle/index.d.ts +0 -9
- package/es/utils/realCircle/index.mjs +0 -10
- package/lib/components/ol-map/index.vue.js +0 -1
- package/lib/components/ol-map/index.vue2.js +0 -1
- package/lib/utils/calculate/index.d.ts +0 -24
- package/lib/utils/calculate/index.js +0 -1
- package/lib/utils/calculate/index.test.d.ts +0 -1
- package/lib/utils/format/index.d.ts +0 -4
- package/lib/utils/format/index.js +0 -1
- package/lib/utils/realCircle/index.d.ts +0 -9
- package/lib/utils/realCircle/index.js +0 -1
|
@@ -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 };
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { inject
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
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 {
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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 {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import "ol/layer";
|
|
10
|
-
import "ol/source";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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 };
|