@summeruse/ol 0.2.0-alpha.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/index.js +58 -64
- package/es/composables/usePointermove/index.d.ts +1 -3
- package/es/composables/usePointermove/index.mjs +56 -62
- package/lib/composables/usePointermove/index.d.ts +1 -3
- package/lib/composables/usePointermove/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @summeruse/ol
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 95fc65d: refactor(usePointermove): 重构指针移动事件处理逻辑
|
|
8
|
+
|
|
9
|
+
## 0.2.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- c2ad696: 将 n-ol-pointermove 组件重构为 usePointermove 组合式函数
|
|
14
|
+
- 6fbc681: 重构右键菜单功能为组合式 API
|
|
15
|
+
- f605ee4: 移除对 naive-ui 的依赖并调整相关配置
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- fd8d77c: 修复 createFeature 中样式不生效
|
|
20
|
+
- 9275a0b: refactor(utils): 移除计算和格式化工具模块
|
|
21
|
+
- 66a195e: refactor(utils/layer): 移除 T_MAP_TYPE 的外部依赖并内联定义
|
|
22
|
+
- 93d2746: refactor(usePointermove): 重构指针移动逻辑并添加新配置选项
|
|
23
|
+
- 3317ecf: feat(utils): 添加角度和旋转格式化函数
|
|
24
|
+
- c466dde: build(ol): 清理 package.json 中未使用的依赖项
|
|
25
|
+
- 03fc086: feat(ol-map): 添加地图事件监听和 emit 功能
|
|
26
|
+
- ba32d77: refactor(utils/layer): 重构地图图层工具函数,优化类型定义和参数结构
|
|
27
|
+
|
|
3
28
|
## 0.2.0-alpha.3
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -619,96 +619,90 @@ function useGraticule(a) {
|
|
|
619
619
|
deep: !0
|
|
620
620
|
}), { showGraticule: u };
|
|
621
621
|
}
|
|
622
|
-
function usePointermove({ mapRef: u, items: d,
|
|
623
|
-
let
|
|
622
|
+
function usePointermove({ mapRef: u, items: d, forceUpdate: f = !1 }) {
|
|
623
|
+
let m = ref(!1), h = ref({
|
|
624
624
|
x: 0,
|
|
625
625
|
y: 0
|
|
626
|
-
}),
|
|
626
|
+
}), g = ref(), _ = ref(), y = ref({
|
|
627
627
|
x: 0,
|
|
628
628
|
y: 0
|
|
629
|
-
}),
|
|
630
|
-
x:
|
|
631
|
-
y:
|
|
632
|
-
})), E
|
|
633
|
-
function
|
|
629
|
+
}), b = ref(), S = ref(), w = computed(() => ({
|
|
630
|
+
x: h.value.x + y.value.x,
|
|
631
|
+
y: h.value.y + y.value.y
|
|
632
|
+
})), T, E, D = "";
|
|
633
|
+
function O(a) {
|
|
634
634
|
let u = toValue(d);
|
|
635
635
|
return u.sort((a, u) => (u.priority ?? 0) - (a.priority ?? 0)), u.find((u) => {
|
|
636
636
|
let d = u.visible;
|
|
637
637
|
return typeof d == "function" ? d(a) : d ?? !0;
|
|
638
638
|
});
|
|
639
639
|
}
|
|
640
|
-
function
|
|
641
|
-
if (!E
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
if (
|
|
646
|
-
|
|
647
|
-
S.value = u;
|
|
648
|
-
let d = D.getEventPixel(a), f, p;
|
|
649
|
-
if (D.forEachFeatureAtPixel(d, (a, u) => (f = a, p = u, !0)), !f) {
|
|
650
|
-
M();
|
|
640
|
+
function k(a) {
|
|
641
|
+
if (a.dragging || !T || !E) return;
|
|
642
|
+
let u = a.coordinate;
|
|
643
|
+
b.value = u;
|
|
644
|
+
let d = a.pixel, p, v;
|
|
645
|
+
if (T.forEachFeatureAtPixel(d, (a, u) => (p = a, v = u, !0)), !p) {
|
|
646
|
+
A();
|
|
651
647
|
return;
|
|
652
648
|
}
|
|
653
|
-
if (!
|
|
654
|
-
|
|
655
|
-
let
|
|
656
|
-
map:
|
|
649
|
+
if (!f && g.value && g.value.getId() === p.getId()) return;
|
|
650
|
+
g.value = p;
|
|
651
|
+
let { top: x, left: C } = E.getBoundingClientRect(), w = {
|
|
652
|
+
map: T,
|
|
657
653
|
position: {
|
|
658
|
-
x:
|
|
659
|
-
y:
|
|
654
|
+
x: d[0] + C,
|
|
655
|
+
y: d[1] + x
|
|
660
656
|
},
|
|
661
657
|
coordinate: u,
|
|
662
|
-
feature:
|
|
663
|
-
layer:
|
|
664
|
-
},
|
|
665
|
-
if (
|
|
666
|
-
let { content: a, cursor: u, visible: d, fixedFeatureCenter: f, offset: p, priority: m,...h } =
|
|
667
|
-
|
|
658
|
+
feature: p,
|
|
659
|
+
layer: v
|
|
660
|
+
}, D = O(w);
|
|
661
|
+
if (D) {
|
|
662
|
+
let { content: a, cursor: u, visible: d, fixedFeatureCenter: f, offset: p, priority: m,...h } = D;
|
|
663
|
+
S.value = { ...h };
|
|
668
664
|
}
|
|
669
|
-
if (!
|
|
670
|
-
|
|
665
|
+
if (!D) {
|
|
666
|
+
A();
|
|
671
667
|
return;
|
|
672
668
|
}
|
|
673
|
-
|
|
674
|
-
x:
|
|
675
|
-
y:
|
|
669
|
+
y.value = {
|
|
670
|
+
x: D.offset?.x ?? 0,
|
|
671
|
+
y: D.offset?.y ?? 0
|
|
676
672
|
};
|
|
677
|
-
let
|
|
678
|
-
if (
|
|
679
|
-
let a = getCenter(
|
|
680
|
-
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
let
|
|
686
|
-
|
|
687
|
-
let j = x.cursor, N = typeof j == "function" ? j(v) : j;
|
|
688
|
-
N !== void 0 && N !== O.style.cursor && (O.style.cursor = N), h.value = !0;
|
|
673
|
+
let k = f === !1 ? !0 : D.fixedFeatureCenter ?? !0, j = p.getGeometry();
|
|
674
|
+
if (k && j) {
|
|
675
|
+
let a = getCenter(j.getExtent());
|
|
676
|
+
d = T.getPixelFromCoordinate(a);
|
|
677
|
+
}
|
|
678
|
+
h.value.x = d[0] + C, h.value.y = d[1] + x;
|
|
679
|
+
let M = D.content;
|
|
680
|
+
_.value = typeof M == "function" ? () => M(w) : M;
|
|
681
|
+
let N = D.cursor, P = typeof N == "function" ? N(w) : N;
|
|
682
|
+
P !== void 0 && P !== E.style.cursor && (E.style.cursor = P), m.value = !0;
|
|
689
683
|
}
|
|
690
|
-
function
|
|
691
|
-
|
|
684
|
+
function A() {
|
|
685
|
+
m.value = !1, g.value = void 0, E && E.style.cursor !== D && (E.style.cursor = D);
|
|
692
686
|
}
|
|
693
|
-
function
|
|
694
|
-
a.
|
|
687
|
+
function j(a) {
|
|
688
|
+
a.on("pointermove", k);
|
|
695
689
|
}
|
|
696
|
-
function
|
|
697
|
-
a.
|
|
690
|
+
function M(a) {
|
|
691
|
+
a.un("pointermove", k);
|
|
698
692
|
}
|
|
699
693
|
return watch(() => toValue(u), (a, u) => {
|
|
700
|
-
u !== a && (
|
|
694
|
+
u && M(u), u !== a && (T = a, a && (E = a.getViewport(), j(a), D = E.style.cursor));
|
|
701
695
|
}, { immediate: !0 }), onBeforeUnmount(() => {
|
|
702
|
-
|
|
696
|
+
T && M(T);
|
|
703
697
|
}), {
|
|
704
|
-
visible: computed(() =>
|
|
705
|
-
position: computed(() =>
|
|
706
|
-
originalPosition: computed(() =>
|
|
707
|
-
feature: computed(() =>
|
|
708
|
-
content: computed(() =>
|
|
709
|
-
coordinate: computed(() =>
|
|
710
|
-
option: computed(() =>
|
|
711
|
-
hide:
|
|
698
|
+
visible: computed(() => m.value),
|
|
699
|
+
position: computed(() => w.value),
|
|
700
|
+
originalPosition: computed(() => h.value),
|
|
701
|
+
feature: computed(() => g.value),
|
|
702
|
+
content: computed(() => _.value),
|
|
703
|
+
coordinate: computed(() => b.value),
|
|
704
|
+
option: computed(() => S.value),
|
|
705
|
+
hide: A
|
|
712
706
|
};
|
|
713
707
|
}
|
|
714
708
|
function useSwitchBaseLayer(a) {
|
|
@@ -40,12 +40,10 @@ export interface UsePointermoveOptions<T extends Option = Option> {
|
|
|
40
40
|
mapRef: MaybeRefOrGetter<OLMap | undefined>;
|
|
41
41
|
/** 提示配置列表 */
|
|
42
42
|
items: MaybeRefOrGetter<PointermoveList<T>>;
|
|
43
|
-
/** 前置判断条件 */
|
|
44
|
-
enabled?: boolean | (() => boolean | undefined | void);
|
|
45
43
|
/** 强制更新 (开启后,无论 feature 是否变化,都强制更新提示) */
|
|
46
44
|
forceUpdate?: boolean;
|
|
47
45
|
}
|
|
48
|
-
export declare function usePointermove<T extends Option>({ mapRef, items,
|
|
46
|
+
export declare function usePointermove<T extends Option>({ mapRef, items, forceUpdate }: UsePointermoveOptions<T>): {
|
|
49
47
|
visible: import('vue').ComputedRef<boolean>;
|
|
50
48
|
position: import('vue').ComputedRef<{
|
|
51
49
|
x: number;
|
|
@@ -1,95 +1,89 @@
|
|
|
1
1
|
import { computed, onBeforeUnmount, ref, toValue, watch } from "vue";
|
|
2
2
|
import { getCenter } from "ol/extent";
|
|
3
|
-
function usePointermove({ mapRef: o, items: s,
|
|
4
|
-
let
|
|
3
|
+
function usePointermove({ mapRef: o, items: s, forceUpdate: c = !1 }) {
|
|
4
|
+
let l = ref(!1), u = ref({
|
|
5
5
|
x: 0,
|
|
6
6
|
y: 0
|
|
7
|
-
}),
|
|
7
|
+
}), d = ref(), f = ref(), p = ref({
|
|
8
8
|
x: 0,
|
|
9
9
|
y: 0
|
|
10
|
-
}),
|
|
11
|
-
x:
|
|
12
|
-
y:
|
|
13
|
-
})), v
|
|
14
|
-
function
|
|
10
|
+
}), m = ref(), h = ref(), g = computed(() => ({
|
|
11
|
+
x: u.value.x + p.value.x,
|
|
12
|
+
y: u.value.y + p.value.y
|
|
13
|
+
})), _, v, y = "";
|
|
14
|
+
function b(e) {
|
|
15
15
|
let t = toValue(s);
|
|
16
16
|
return t.sort((e, t) => (t.priority ?? 0) - (e.priority ?? 0)), t.find((t) => {
|
|
17
17
|
let n = t.visible;
|
|
18
18
|
return typeof n == "function" ? n(e) : n ?? !0;
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
if (!v
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
h.value = t;
|
|
29
|
-
let n = y.getEventPixel(e), r, i;
|
|
30
|
-
if (y.forEachFeatureAtPixel(n, (e, t) => (r = e, i = t, !0)), !r) {
|
|
31
|
-
w();
|
|
21
|
+
function x(e) {
|
|
22
|
+
if (e.dragging || !_ || !v) return;
|
|
23
|
+
let t = e.coordinate;
|
|
24
|
+
m.value = t;
|
|
25
|
+
let n = e.pixel, r, i;
|
|
26
|
+
if (_.forEachFeatureAtPixel(n, (e, t) => (r = e, i = t, !0)), !r) {
|
|
27
|
+
S();
|
|
32
28
|
return;
|
|
33
29
|
}
|
|
34
|
-
if (!
|
|
35
|
-
|
|
36
|
-
let o = {
|
|
37
|
-
map:
|
|
30
|
+
if (!c && d.value && d.value.getId() === r.getId()) return;
|
|
31
|
+
d.value = r;
|
|
32
|
+
let { top: o, left: s } = v.getBoundingClientRect(), g = {
|
|
33
|
+
map: _,
|
|
38
34
|
position: {
|
|
39
|
-
x:
|
|
40
|
-
y:
|
|
35
|
+
x: n[0] + s,
|
|
36
|
+
y: n[1] + o
|
|
41
37
|
},
|
|
42
38
|
coordinate: t,
|
|
43
39
|
feature: r,
|
|
44
40
|
layer: i
|
|
45
|
-
},
|
|
46
|
-
if (
|
|
47
|
-
let { content: e, cursor: t, visible: n, fixedFeatureCenter: r, offset: i, priority: a,...o } =
|
|
48
|
-
|
|
41
|
+
}, y = b(g);
|
|
42
|
+
if (y) {
|
|
43
|
+
let { content: e, cursor: t, visible: n, fixedFeatureCenter: r, offset: i, priority: a,...o } = y;
|
|
44
|
+
h.value = { ...o };
|
|
49
45
|
}
|
|
50
|
-
if (!
|
|
51
|
-
|
|
46
|
+
if (!y) {
|
|
47
|
+
S();
|
|
52
48
|
return;
|
|
53
49
|
}
|
|
54
|
-
|
|
55
|
-
x:
|
|
56
|
-
y:
|
|
50
|
+
p.value = {
|
|
51
|
+
x: y.offset?.x ?? 0,
|
|
52
|
+
y: y.offset?.y ?? 0
|
|
57
53
|
};
|
|
58
|
-
let
|
|
59
|
-
if (
|
|
60
|
-
let e = getCenter(
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
let
|
|
67
|
-
|
|
68
|
-
let C = s.cursor, T = typeof C == "function" ? C(o) : C;
|
|
69
|
-
T !== void 0 && T !== b.style.cursor && (b.style.cursor = T), u.value = !0;
|
|
54
|
+
let x = c === !1 ? !0 : y.fixedFeatureCenter ?? !0, C = r.getGeometry();
|
|
55
|
+
if (x && C) {
|
|
56
|
+
let e = getCenter(C.getExtent());
|
|
57
|
+
n = _.getPixelFromCoordinate(e);
|
|
58
|
+
}
|
|
59
|
+
u.value.x = n[0] + s, u.value.y = n[1] + o;
|
|
60
|
+
let w = y.content;
|
|
61
|
+
f.value = typeof w == "function" ? () => w(g) : w;
|
|
62
|
+
let T = y.cursor, E = typeof T == "function" ? T(g) : T;
|
|
63
|
+
E !== void 0 && E !== v.style.cursor && (v.style.cursor = E), l.value = !0;
|
|
70
64
|
}
|
|
71
|
-
function
|
|
72
|
-
|
|
65
|
+
function S() {
|
|
66
|
+
l.value = !1, d.value = void 0, v && v.style.cursor !== y && (v.style.cursor = y);
|
|
73
67
|
}
|
|
74
|
-
function
|
|
75
|
-
e.
|
|
68
|
+
function C(e) {
|
|
69
|
+
e.on("pointermove", x);
|
|
76
70
|
}
|
|
77
|
-
function
|
|
78
|
-
e.
|
|
71
|
+
function w(e) {
|
|
72
|
+
e.un("pointermove", x);
|
|
79
73
|
}
|
|
80
74
|
return watch(() => toValue(o), (e, t) => {
|
|
81
|
-
t !== e && (
|
|
75
|
+
t && w(t), t !== e && (_ = e, e && (v = e.getViewport(), C(e), y = v.style.cursor));
|
|
82
76
|
}, { immediate: !0 }), onBeforeUnmount(() => {
|
|
83
|
-
|
|
77
|
+
_ && w(_);
|
|
84
78
|
}), {
|
|
85
|
-
visible: computed(() =>
|
|
86
|
-
position: computed(() =>
|
|
87
|
-
originalPosition: computed(() =>
|
|
88
|
-
feature: computed(() =>
|
|
89
|
-
content: computed(() =>
|
|
90
|
-
coordinate: computed(() =>
|
|
91
|
-
option: computed(() =>
|
|
92
|
-
hide:
|
|
79
|
+
visible: computed(() => l.value),
|
|
80
|
+
position: computed(() => g.value),
|
|
81
|
+
originalPosition: computed(() => u.value),
|
|
82
|
+
feature: computed(() => d.value),
|
|
83
|
+
content: computed(() => f.value),
|
|
84
|
+
coordinate: computed(() => m.value),
|
|
85
|
+
option: computed(() => h.value),
|
|
86
|
+
hide: S
|
|
93
87
|
};
|
|
94
88
|
}
|
|
95
89
|
export { usePointermove };
|
|
@@ -40,12 +40,10 @@ export interface UsePointermoveOptions<T extends Option = Option> {
|
|
|
40
40
|
mapRef: MaybeRefOrGetter<OLMap | undefined>;
|
|
41
41
|
/** 提示配置列表 */
|
|
42
42
|
items: MaybeRefOrGetter<PointermoveList<T>>;
|
|
43
|
-
/** 前置判断条件 */
|
|
44
|
-
enabled?: boolean | (() => boolean | undefined | void);
|
|
45
43
|
/** 强制更新 (开启后,无论 feature 是否变化,都强制更新提示) */
|
|
46
44
|
forceUpdate?: boolean;
|
|
47
45
|
}
|
|
48
|
-
export declare function usePointermove<T extends Option>({ mapRef, items,
|
|
46
|
+
export declare function usePointermove<T extends Option>({ mapRef, items, forceUpdate }: UsePointermoveOptions<T>): {
|
|
49
47
|
visible: import('vue').ComputedRef<boolean>;
|
|
50
48
|
position: import('vue').ComputedRef<{
|
|
51
49
|
x: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../_virtual/rolldown_runtime.js`);let t=require(`vue`);t=e.__toESM(t);let n=require(`ol/extent`);n=e.__toESM(n);function r({mapRef:e,items:r,
|
|
1
|
+
const e=require(`../../_virtual/rolldown_runtime.js`);let t=require(`vue`);t=e.__toESM(t);let n=require(`ol/extent`);n=e.__toESM(n);function r({mapRef:e,items:r,forceUpdate:i=!1}){let a=(0,t.ref)(!1),o=(0,t.ref)({x:0,y:0}),s=(0,t.ref)(),c=(0,t.ref)(),l=(0,t.ref)({x:0,y:0}),u=(0,t.ref)(),d=(0,t.ref)(),f=(0,t.computed)(()=>({x:o.value.x+l.value.x,y:o.value.y+l.value.y})),p,m,h=``;function g(e){let n=(0,t.toValue)(r);return n.sort((e,t)=>(t.priority??0)-(e.priority??0)),n.find(t=>{let n=t.visible;return typeof n==`function`?n(e):n??!0})}function _(e){if(e.dragging||!p||!m)return;let t=e.coordinate;u.value=t;let r=e.pixel,f,h;if(p.forEachFeatureAtPixel(r,(e,t)=>(f=e,h=t,!0)),!f){v();return}if(!i&&s.value&&s.value.getId()===f.getId())return;s.value=f;let{top:_,left:y}=m.getBoundingClientRect(),b={map:p,position:{x:r[0]+y,y:r[1]+_},coordinate:t,feature:f,layer:h},x=g(b);if(x){let{content:e,cursor:t,visible:n,fixedFeatureCenter:r,offset:i,priority:a,...o}=x;d.value={...o}}if(!x){v();return}l.value={x:x.offset?.x??0,y:x.offset?.y??0};let S=i===!1?!0:x.fixedFeatureCenter??!0,C=f.getGeometry();if(S&&C){let e=(0,n.getCenter)(C.getExtent());r=p.getPixelFromCoordinate(e)}o.value.x=r[0]+y,o.value.y=r[1]+_;let w=x.content;c.value=typeof w==`function`?()=>w(b):w;let T=x.cursor,E=typeof T==`function`?T(b):T;E!==void 0&&E!==m.style.cursor&&(m.style.cursor=E),a.value=!0}function v(){a.value=!1,s.value=void 0,m&&m.style.cursor!==h&&(m.style.cursor=h)}function y(e){e.on(`pointermove`,_)}function b(e){e.un(`pointermove`,_)}return(0,t.watch)(()=>(0,t.toValue)(e),(e,t)=>{t&&b(t),t!==e&&(p=e,e&&(m=e.getViewport(),y(e),h=m.style.cursor))},{immediate:!0}),(0,t.onBeforeUnmount)(()=>{p&&b(p)}),{visible:(0,t.computed)(()=>a.value),position:(0,t.computed)(()=>f.value),originalPosition:(0,t.computed)(()=>o.value),feature:(0,t.computed)(()=>s.value),content:(0,t.computed)(()=>c.value),coordinate:(0,t.computed)(()=>u.value),option:(0,t.computed)(()=>d.value),hide:v}}exports.usePointermove=r;
|