@summeruse/ol 0.3.2 → 0.4.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.
Files changed (99) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +70 -8
  3. package/dist/index.d.ts +665 -0
  4. package/dist/index.iife.min.js +4 -0
  5. package/dist/index.js +9930 -554
  6. package/package.json +13 -18
  7. package/es/components/index.d.ts +0 -1
  8. package/es/components/index.mjs +0 -3
  9. package/es/components/ol-map/index.d.ts +0 -4
  10. package/es/components/ol-map/index.mjs +0 -3
  11. package/es/components/ol-map/index.test.d.ts +0 -1
  12. package/es/components/ol-map/index.vue.d.ts +0 -59
  13. package/es/components/ol-map/index.vue_vue_type_script_setup_true_lang.mjs +0 -151
  14. package/es/components/ol-map/index2.mjs +0 -2
  15. package/es/components/ol-map/props.d.ts +0 -38
  16. package/es/components/ol-map/props.mjs +0 -6
  17. package/es/composables/common/index.d.ts +0 -1
  18. package/es/composables/common/index.mjs +0 -5
  19. package/es/composables/index.d.ts +0 -6
  20. package/es/composables/index.mjs +0 -6
  21. package/es/composables/useContextmenu/index.d.ts +0 -71
  22. package/es/composables/useContextmenu/index.mjs +0 -71
  23. package/es/composables/useDrawLineString/index.d.ts +0 -109
  24. package/es/composables/useDrawLineString/index.mjs +0 -105
  25. package/es/composables/useDrawPolygon/index.d.ts +0 -109
  26. package/es/composables/useDrawPolygon/index.mjs +0 -106
  27. package/es/composables/useGraticule/index.d.ts +0 -20
  28. package/es/composables/useGraticule/index.mjs +0 -23
  29. package/es/composables/usePointermove/index.d.ts +0 -70
  30. package/es/composables/usePointermove/index.mjs +0 -91
  31. package/es/composables/useSwitchBaseLayer/index.d.ts +0 -11
  32. package/es/composables/useSwitchBaseLayer/index.mjs +0 -17
  33. package/es/constants/distance.d.ts +0 -1
  34. package/es/constants/distance.mjs +0 -2
  35. package/es/constants/index.d.ts +0 -2
  36. package/es/constants/projection.d.ts +0 -9
  37. package/es/constants/projection.mjs +0 -2
  38. package/es/index.d.ts +0 -4
  39. package/es/index.mjs +0 -19
  40. package/es/types/index.d.ts +0 -4
  41. package/es/utils/distance/index.d.ts +0 -8
  42. package/es/utils/distance/index.mjs +0 -14
  43. package/es/utils/feature/index.d.ts +0 -26
  44. package/es/utils/feature/index.mjs +0 -81
  45. package/es/utils/index.d.ts +0 -5
  46. package/es/utils/index.mjs +0 -5
  47. package/es/utils/layer/index.d.ts +0 -60
  48. package/es/utils/layer/index.mjs +0 -70
  49. package/es/utils/projection/index.d.ts +0 -18
  50. package/es/utils/projection/index.mjs +0 -19
  51. package/es/utils/style/index.d.ts +0 -27
  52. package/es/utils/style/index.mjs +0 -30
  53. package/lib/_virtual/rolldown_runtime.js +0 -1
  54. package/lib/components/index.d.ts +0 -1
  55. package/lib/components/index.js +0 -1
  56. package/lib/components/ol-map/index.d.ts +0 -4
  57. package/lib/components/ol-map/index.js +0 -1
  58. package/lib/components/ol-map/index.test.d.ts +0 -1
  59. package/lib/components/ol-map/index.vue.d.ts +0 -59
  60. package/lib/components/ol-map/index.vue_vue_type_script_setup_true_lang.js +0 -1
  61. package/lib/components/ol-map/index2.js +0 -1
  62. package/lib/components/ol-map/props.d.ts +0 -38
  63. package/lib/components/ol-map/props.js +0 -1
  64. package/lib/composables/common/index.d.ts +0 -1
  65. package/lib/composables/common/index.js +0 -1
  66. package/lib/composables/index.d.ts +0 -6
  67. package/lib/composables/index.js +0 -1
  68. package/lib/composables/useContextmenu/index.d.ts +0 -71
  69. package/lib/composables/useContextmenu/index.js +0 -1
  70. package/lib/composables/useDrawLineString/index.d.ts +0 -109
  71. package/lib/composables/useDrawLineString/index.js +0 -1
  72. package/lib/composables/useDrawPolygon/index.d.ts +0 -109
  73. package/lib/composables/useDrawPolygon/index.js +0 -1
  74. package/lib/composables/useGraticule/index.d.ts +0 -20
  75. package/lib/composables/useGraticule/index.js +0 -1
  76. package/lib/composables/usePointermove/index.d.ts +0 -70
  77. package/lib/composables/usePointermove/index.js +0 -1
  78. package/lib/composables/useSwitchBaseLayer/index.d.ts +0 -11
  79. package/lib/composables/useSwitchBaseLayer/index.js +0 -1
  80. package/lib/constants/distance.d.ts +0 -1
  81. package/lib/constants/distance.js +0 -1
  82. package/lib/constants/index.d.ts +0 -2
  83. package/lib/constants/projection.d.ts +0 -9
  84. package/lib/constants/projection.js +0 -1
  85. package/lib/index.d.ts +0 -4
  86. package/lib/index.js +0 -1
  87. package/lib/types/index.d.ts +0 -4
  88. package/lib/utils/distance/index.d.ts +0 -8
  89. package/lib/utils/distance/index.js +0 -1
  90. package/lib/utils/feature/index.d.ts +0 -26
  91. package/lib/utils/feature/index.js +0 -1
  92. package/lib/utils/index.d.ts +0 -5
  93. package/lib/utils/index.js +0 -1
  94. package/lib/utils/layer/index.d.ts +0 -60
  95. package/lib/utils/layer/index.js +0 -1
  96. package/lib/utils/projection/index.d.ts +0 -18
  97. package/lib/utils/projection/index.js +0 -1
  98. package/lib/utils/style/index.d.ts +0 -27
  99. package/lib/utils/style/index.js +0 -1
@@ -1,105 +0,0 @@
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
- };
104
- }
105
- export { useDrawLineString };
@@ -1,109 +0,0 @@
1
- import { Coordinate } from 'ol/coordinate';
2
- import { Style } from 'ol/style';
3
- import { VNode } from 'vue';
4
- import { OLMap } from '../../types';
5
- import { StyleOptions } from '../../utils';
6
- import { Feature } from 'ol';
7
- import { Polygon } from 'ol/geom';
8
- export interface DrawPolygonOptions {
9
- defaultCoordinates?: Coordinate[][][];
10
- deletePointLabel?: VNode;
11
- deleteFeatureLabel?: VNode;
12
- style?: Style;
13
- styleOptions?: StyleOptions;
14
- drawStyleOptions?: StyleOptions;
15
- modifyStyleOptions?: StyleOptions;
16
- drawStyle?: Style;
17
- modifyStyle?: Style;
18
- zIndex?: number;
19
- size?: number;
20
- }
21
- export declare function useDrawPolygon(olMap: OLMap, options: DrawPolygonOptions): {
22
- inDraw: import('vue').Ref<boolean, boolean>;
23
- start: () => void;
24
- stop: () => void;
25
- clear: () => void;
26
- setFeatures: (coordinates?: Coordinate[][][]) => void;
27
- reset: () => void;
28
- features: import('vue').Ref<{
29
- on: import('ol/Feature').FeatureOnSignature<import('ol/events').EventsKey>;
30
- once: import('ol/Feature').FeatureOnSignature<import('ol/events').EventsKey>;
31
- un: import('ol/Feature').FeatureOnSignature<void>;
32
- clone: () => Feature<Polygon>;
33
- getGeometry: () => Polygon | undefined;
34
- getId: () => number | string | undefined;
35
- getGeometryName: () => string;
36
- getStyle: () => import('ol/style/Style').StyleLike | undefined;
37
- getStyleFunction: () => import('ol/style/Style').StyleFunction | undefined;
38
- setGeometry: (geometry: Polygon | undefined) => void;
39
- setStyle: (style?: import('ol/style/Style').StyleLike) => void;
40
- setId: (id: number | string | undefined) => void;
41
- setGeometryName: (name: string) => void;
42
- get: (key: string) => any;
43
- getKeys: () => Array<string>;
44
- getProperties: () => {
45
- [x: string]: any;
46
- };
47
- getPropertiesInternal: () => {
48
- [x: string]: any;
49
- } | null;
50
- hasProperties: () => boolean;
51
- notify: (key: string, oldValue: any) => void;
52
- addChangeListener: (key: string, listener: import('ol/events').Listener) => void;
53
- removeChangeListener: (key: string, listener: import('ol/events').Listener) => void;
54
- set: (key: string, value: any, silent?: boolean) => void;
55
- setProperties: (values: {
56
- [x: string]: any;
57
- }, silent?: boolean) => void;
58
- unset: (key: string, silent?: boolean) => void;
59
- changed: () => void;
60
- getRevision: () => number;
61
- addEventListener: (type: string, listener: import('ol/events').Listener) => void;
62
- dispatchEvent: (event: import('ol/events/Event').default | string) => boolean | undefined;
63
- getListeners: (type: string) => Array<import('ol/events').Listener> | undefined;
64
- hasListener: (type?: string) => boolean;
65
- removeEventListener: (type: string, listener: import('ol/events').Listener) => void;
66
- dispose: () => void;
67
- }[], Feature<Polygon>[] | {
68
- on: import('ol/Feature').FeatureOnSignature<import('ol/events').EventsKey>;
69
- once: import('ol/Feature').FeatureOnSignature<import('ol/events').EventsKey>;
70
- un: import('ol/Feature').FeatureOnSignature<void>;
71
- clone: () => Feature<Polygon>;
72
- getGeometry: () => Polygon | undefined;
73
- getId: () => number | string | undefined;
74
- getGeometryName: () => string;
75
- getStyle: () => import('ol/style/Style').StyleLike | undefined;
76
- getStyleFunction: () => import('ol/style/Style').StyleFunction | undefined;
77
- setGeometry: (geometry: Polygon | undefined) => void;
78
- setStyle: (style?: import('ol/style/Style').StyleLike) => void;
79
- setId: (id: number | string | undefined) => void;
80
- setGeometryName: (name: string) => void;
81
- get: (key: string) => any;
82
- getKeys: () => Array<string>;
83
- getProperties: () => {
84
- [x: string]: any;
85
- };
86
- getPropertiesInternal: () => {
87
- [x: string]: any;
88
- } | null;
89
- hasProperties: () => boolean;
90
- notify: (key: string, oldValue: any) => void;
91
- addChangeListener: (key: string, listener: import('ol/events').Listener) => void;
92
- removeChangeListener: (key: string, listener: import('ol/events').Listener) => void;
93
- set: (key: string, value: any, silent?: boolean) => void;
94
- setProperties: (values: {
95
- [x: string]: any;
96
- }, silent?: boolean) => void;
97
- unset: (key: string, silent?: boolean) => void;
98
- changed: () => void;
99
- getRevision: () => number;
100
- addEventListener: (type: string, listener: import('ol/events').Listener) => void;
101
- dispatchEvent: (event: import('ol/events/Event').default | string) => boolean | undefined;
102
- getListeners: (type: string) => Array<import('ol/events').Listener> | undefined;
103
- hasListener: (type?: string) => boolean;
104
- removeEventListener: (type: string, listener: import('ol/events').Listener) => void;
105
- dispose: () => void;
106
- }[]>;
107
- coordinates: import('vue').ComputedRef<Coordinate[][][]>;
108
- destroy: () => void;
109
- };
@@ -1,106 +0,0 @@
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 { Polygon } from "ol/geom";
9
- import VectorLayer from "ol/layer/Vector";
10
- import VectorSource from "ol/source/Vector";
11
- function useDrawPolygon(h, g) {
12
- let _ = ref(!0), v = ref([]), y = computed(() => v.value.map((e) => e.getGeometry().getCoordinates())), b = g.styleOptions ? createStyle(g.styleOptions) : g?.style, x = new VectorSource(), S = new VectorLayer({
13
- source: x,
14
- style: b,
15
- zIndex: g?.zIndex
16
- });
17
- h.addLayer(S);
18
- let C = new Draw({
19
- source: x,
20
- style: (g.drawStyleOptions ? createStyle(g.drawStyleOptions) : g?.drawStyle) || b,
21
- type: "Polygon"
22
- });
23
- C.setActive(!1);
24
- let w = new Modify({
25
- source: x,
26
- style: (g.modifyStyleOptions ? createStyle(g.modifyStyleOptions) : g?.modifyStyle) || b
27
- }), T = /* @__PURE__ */ new Set();
28
- h.addInteraction(C), onMounted(() => {
29
- h.addInteraction(w);
30
- }), x.on("addfeature", () => {
31
- g.size && x.getFeatures().length >= g.size && C.setActive(!1);
32
- }), x.on("removefeature", () => {
33
- g.size && x.getFeatures().length < g.size && C.setActive(!0);
34
- });
35
- let E = () => {
36
- T.forEach((e) => {
37
- h.removeOverlay(e);
38
- }), T.clear();
39
- };
40
- x.on("change", () => {
41
- E(), x.getFeatures().forEach((e) => {
42
- let u = e.getGeometry(), d = getCenter(u.getExtent()), f = document.createElement("div");
43
- g.deleteFeatureLabel ? render(g.deleteFeatureLabel, f) : f = createToolTipElement("删除区域"), f.addEventListener("click", () => {
44
- x.removeFeature(e);
45
- });
46
- let p = new Overlay({
47
- position: d,
48
- positioning: "center-center",
49
- element: f
50
- });
51
- T.add(p), h.addOverlay(p);
52
- let m = u.getCoordinates()[0];
53
- m.length < 3 || m.forEach((u, d) => {
54
- let f = document.createElement("div");
55
- g.deletePointLabel ? render(g.deletePointLabel, f) : f = createToolTipElement("删除点"), f.addEventListener("click", () => {
56
- e.setGeometry(new Polygon([m.filter((e, l) => l !== d)]));
57
- });
58
- let p = new Overlay({
59
- position: u,
60
- positioning: "top-center",
61
- offset: [0, -30],
62
- element: f
63
- });
64
- T.add(p), h.addOverlay(p);
65
- });
66
- });
67
- }), C.on("change:active", () => {
68
- _.value = C.getActive();
69
- }), x.on("change", () => {
70
- v.value = x.getFeatures();
71
- });
72
- let D = () => {
73
- E(), h.removeLayer(S), h.removeInteraction(C), h.removeInteraction(w);
74
- }, O = () => {
75
- g.size && v.value.length >= g.size || C.setActive(!0);
76
- }, k = () => {
77
- C.setActive(!1);
78
- }, A = (e) => {
79
- x.clear(), e?.forEach((e) => {
80
- e.forEach((e) => {
81
- if (e.length < 2) return;
82
- e[0] !== e[e.length - 1] && e.push(e[0]);
83
- let l = new Feature({ geometry: new Polygon([e]) });
84
- x.addFeature(l);
85
- });
86
- });
87
- }, j = () => {
88
- A(g.defaultCoordinates);
89
- };
90
- return j(), onUnmounted(() => {
91
- D();
92
- }), {
93
- inDraw: _,
94
- start: O,
95
- stop: k,
96
- clear: () => {
97
- x.clear(), k();
98
- },
99
- setFeatures: A,
100
- reset: j,
101
- features: v,
102
- coordinates: y,
103
- destroy: D
104
- };
105
- }
106
- export { useDrawPolygon };
@@ -1,20 +0,0 @@
1
- import { Map as OLMap } from 'ol';
2
- import { MaybeRef, Ref } from 'vue';
3
- import { StrokeOptions, TextOptions } from '../../utils';
4
- import { Graticule } from 'ol/layer';
5
- export type _GraticuleOptions = ConstructorParameters<typeof Graticule>[0];
6
- export type GraticuleOptions = _GraticuleOptions & {
7
- strokeStyleOption?: StrokeOptions;
8
- labelStyleOption?: TextOptions;
9
- latLabelStyleOption?: TextOptions;
10
- lonLabelStyleOption?: TextOptions;
11
- };
12
- export interface UseGraticuleOptions {
13
- olMap: MaybeRef<OLMap | null | undefined>;
14
- graticuleOptions?: GraticuleOptions;
15
- defaultShow?: boolean;
16
- }
17
- export declare function useGraticule(options: UseGraticuleOptions): {
18
- showGraticule: Ref<boolean, boolean>;
19
- };
20
- export type UseGraticuleReturn = ReturnType<typeof useGraticule>;
@@ -1,23 +0,0 @@
1
- import { createTextStyle } from "../../utils/style/index.mjs";
2
- import "../../utils/index.mjs";
3
- import { ref, toValue, watch } from "vue";
4
- import { Stroke } from "ol/style";
5
- import { Graticule } from "ol/layer";
6
- function useGraticule(o) {
7
- let s = ref(o.defaultShow || !1), { strokeStyleOption: c, strokeStyle: l, labelStyleOption: u, latLabelStyleOption: d, lonLabelStyleOption: f, latLabelStyle: p, lonLabelStyle: m,...h } = o.graticuleOptions || {}, g = c ? new Stroke(c) : l, _ = u ? createTextStyle(u) : void 0, v = (d ? createTextStyle(d) : p) || _, y = (f ? createTextStyle(f) : m) || _, b = new Graticule({
8
- ...h,
9
- strokeStyle: g,
10
- latLabelStyle: v,
11
- lonLabelStyle: y
12
- });
13
- return watch(s, (e) => {
14
- if (b.setMap(null), e) {
15
- let e = toValue(o.olMap);
16
- e && b.setMap(e);
17
- }
18
- }, {
19
- immediate: !0,
20
- deep: !0
21
- }), { showGraticule: s };
22
- }
23
- export { useGraticule };
@@ -1,70 +0,0 @@
1
- import { Coordinate } from 'ol/coordinate';
2
- import { FeatureLike } from 'ol/Feature';
3
- import { CSSProperties, MaybeRefOrGetter, VNodeChild } from 'vue';
4
- import { LayerLike, OLMap } from '../../types';
5
- export interface PointermovePosition {
6
- x: number;
7
- y: number;
8
- }
9
- interface PointermoveContentParams {
10
- map: OLMap;
11
- coordinate: Coordinate;
12
- position: PointermovePosition;
13
- feature: FeatureLike;
14
- layer?: LayerLike;
15
- }
16
- type Cursor = CSSProperties['cursor'];
17
- export type PointermoveItem<T extends Option = Option> = {
18
- /** 提示内容,支持函数动态生成 */
19
- content?: ((params: PointermoveContentParams) => VNodeChild) | string;
20
- /** 是否显示提示,可根据 feature 动态判断 */
21
- visible?: ((params: PointermoveContentParams) => boolean | undefined | void) | boolean;
22
- /** 位置偏移 */
23
- offset?: {
24
- x?: number;
25
- y?: number;
26
- };
27
- /** 优先级,数字越大优先级越高,当多个 tooltip 匹配时,显示优先级最高的 */
28
- priority?: number;
29
- /** 鼠标样式,如 'pointer', 'crosshair', 'move' 等 */
30
- cursor?: Cursor | ((params: PointermoveContentParams) => Cursor);
31
- /** 固定在feature center 默认启用,若要关闭需要同时开启强制更新 */
32
- fixedFeatureCenter?: boolean;
33
- } & T;
34
- export type PointermoveList<T extends Option = Option> = PointermoveItem<T>[];
35
- export interface Option {
36
- [key: string]: any;
37
- }
38
- export interface UsePointermoveOptions<T extends Option = Option> {
39
- /** 地图实例 */
40
- mapRef: MaybeRefOrGetter<OLMap | undefined>;
41
- /** 提示配置列表 */
42
- items: MaybeRefOrGetter<PointermoveList<T>>;
43
- /** 强制更新 (开启后,无论 feature 是否变化,都强制更新提示) */
44
- forceUpdate?: boolean;
45
- }
46
- export declare function usePointermove<T extends Option>({ mapRef, items, forceUpdate }: UsePointermoveOptions<T>): {
47
- visible: import('vue').ComputedRef<boolean>;
48
- position: import('vue').ComputedRef<{
49
- x: number;
50
- y: number;
51
- }>;
52
- offset: import('vue').ComputedRef<{
53
- x: number;
54
- y: number;
55
- }>;
56
- originalPosition: import('vue').ComputedRef<{
57
- x: number;
58
- y: number;
59
- }>;
60
- feature: import('vue').ComputedRef<FeatureLike | undefined>;
61
- content: import('vue').ComputedRef<string | (() => VNodeChild) | undefined>;
62
- originalCoordinate: import('vue').ComputedRef<Coordinate | undefined>;
63
- coordinate: import('vue').ComputedRef<Coordinate | undefined>;
64
- option: import('vue').ComputedRef<T | undefined>;
65
- hide: () => void;
66
- };
67
- export type UsePointermoveReturn = ReturnType<typeof usePointermove>;
68
- export type UsePointermoveParams<T extends Option> = Parameters<typeof usePointermove<T>>;
69
- export type UsePointermoveFn<T extends Option> = (...args: UsePointermoveParams<T>) => UsePointermoveReturn;
70
- export {};
@@ -1,91 +0,0 @@
1
- import { computed, onBeforeUnmount, ref, toValue, watch } from "vue";
2
- import { getCenter } from "ol/extent";
3
- function usePointermove({ mapRef: o, items: s, forceUpdate: c = !1 }) {
4
- let l = ref(!1), u = ref({
5
- x: 0,
6
- y: 0
7
- }), d = ref(), f = ref(), p = ref({
8
- x: 0,
9
- y: 0
10
- }), m = ref(), h = ref(), g = ref(), _ = computed(() => ({
11
- x: u.value.x + p.value.x,
12
- y: u.value.y + p.value.y
13
- })), v, y, b = "";
14
- function x(e) {
15
- let t = toValue(s);
16
- return t.sort((e, t) => (t.priority ?? 0) - (e.priority ?? 0)), t.find((t) => {
17
- let n = t.visible;
18
- return typeof n == "function" ? n(e) : n ?? !0;
19
- });
20
- }
21
- function S(e) {
22
- if (e.dragging || !v || !y) return;
23
- let t = e.coordinate;
24
- m.value = t, h.value = t;
25
- let n = e.pixel, r, i;
26
- if (v.forEachFeatureAtPixel(n, (e, t) => (r = e, i = t, !0)), !r) {
27
- C();
28
- return;
29
- }
30
- if (!c && d.value && d.value.getId() === r.getId()) return;
31
- d.value = r;
32
- let { top: o, left: s } = y.getBoundingClientRect(), _ = {
33
- map: v,
34
- position: {
35
- x: n[0] + s,
36
- y: n[1] + o
37
- },
38
- coordinate: t,
39
- feature: r,
40
- layer: i
41
- }, b = x(_);
42
- if (b) {
43
- let { content: e, cursor: t, visible: n, fixedFeatureCenter: r, offset: i, priority: a,...o } = b;
44
- g.value = { ...o };
45
- }
46
- if (!b) {
47
- C();
48
- return;
49
- }
50
- p.value = {
51
- x: b.offset?.x ?? 0,
52
- y: b.offset?.y ?? 0
53
- };
54
- let S = c === !1 ? !0 : b.fixedFeatureCenter ?? !0, w = r.getGeometry();
55
- if (S && w) {
56
- let e = getCenter(w.getExtent());
57
- h.value = e, n = v.getPixelFromCoordinate(e);
58
- }
59
- u.value.x = n[0] + s, u.value.y = n[1] + o;
60
- let T = b.content;
61
- f.value = typeof T == "function" ? () => T(_) : T;
62
- let E = b.cursor, D = typeof E == "function" ? E(_) : E;
63
- D !== void 0 && D !== y.style.cursor && (y.style.cursor = D), l.value = !0;
64
- }
65
- function C() {
66
- l.value = !1, d.value = void 0, y && y.style.cursor !== b && (y.style.cursor = b);
67
- }
68
- function w(e) {
69
- e.on("pointermove", S);
70
- }
71
- function T(e) {
72
- e.un("pointermove", S);
73
- }
74
- return watch(() => toValue(o), (e, t) => {
75
- t && T(t), t !== e && (v = e, e && (y = e.getViewport(), w(e), b = y.style.cursor));
76
- }, { immediate: !0 }), onBeforeUnmount(() => {
77
- v && T(v);
78
- }), {
79
- visible: computed(() => l.value),
80
- position: computed(() => _.value),
81
- offset: computed(() => p.value),
82
- originalPosition: computed(() => u.value),
83
- feature: computed(() => d.value),
84
- content: computed(() => f.value),
85
- originalCoordinate: computed(() => m.value),
86
- coordinate: computed(() => h.value),
87
- option: computed(() => g.value),
88
- hide: C
89
- };
90
- }
91
- export { usePointermove };
@@ -1,11 +0,0 @@
1
- import { Map as OLMap } from 'ol';
2
- import { default as TileLayer } from 'ol/layer/Tile';
3
- export declare function useSwitchBaseLayer(data: {
4
- olMap: OLMap;
5
- defaultLayerName?: string;
6
- layers: {
7
- [key: string]: TileLayer[];
8
- };
9
- }): {
10
- visibleLayerName: import('vue').Ref<string, string>;
11
- };
@@ -1,17 +0,0 @@
1
- import { ref, watch } from "vue";
2
- function useSwitchBaseLayer(n) {
3
- let r = ref(n.defaultLayerName || Object.keys(n.layers)[0]);
4
- return Object.values(n.layers).forEach((e) => {
5
- e.forEach((e) => {
6
- n.olMap.addLayer(e);
7
- });
8
- }), watch(r, () => {
9
- Object.entries(n.layers).forEach(([e, t]) => {
10
- let n = e === r.value;
11
- t.forEach((e) => {
12
- e.setVisible(n);
13
- });
14
- });
15
- }, { immediate: !0 }), { visibleLayerName: r };
16
- }
17
- export { useSwitchBaseLayer };
@@ -1 +0,0 @@
1
- export declare const ONE_NM = 1852;
@@ -1,2 +0,0 @@
1
- const ONE_NM = 1852;
2
- export { ONE_NM };
@@ -1,2 +0,0 @@
1
- export * from './distance';
2
- export * from './projection';
@@ -1,9 +0,0 @@
1
- /** 3857坐标系 墨卡托坐标系 */
2
- export declare const EPSG_3857 = "EPSG:3857";
3
- /** 4326坐标系 经纬度坐标系 */
4
- export declare const EPSG_4326 = "EPSG:4326";
5
- /** 3857坐标系 墨卡托坐标系 */
6
- export declare const WebMercatorProjection = "EPSG:3857";
7
- /** 4326坐标系 经纬度坐标系 */
8
- export declare const WGS84Projection = "EPSG:4326";
9
- export type ProjectionLike = 'EPSG:3857' | 'EPSG:4326';
@@ -1,2 +0,0 @@
1
- const EPSG_3857 = "EPSG:3857", EPSG_4326 = "EPSG:4326", WebMercatorProjection = EPSG_3857, WGS84Projection = EPSG_4326;
2
- export { EPSG_3857, EPSG_4326, WGS84Projection, WebMercatorProjection };
package/es/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './components';
2
- export * from './composables';
3
- export * from './constants';
4
- export * from './utils';
package/es/index.mjs DELETED
@@ -1,19 +0,0 @@
1
- import { olMapInjectionKey, useOlMap } from "./components/ol-map/props.mjs";
2
- import ol_map_default from "./components/ol-map/index.mjs";
3
- import "./components/index.mjs";
4
- import { useContextmenu } from "./composables/useContextmenu/index.mjs";
5
- import { ONE_NM } from "./constants/distance.mjs";
6
- import { EPSG_3857, EPSG_4326, WGS84Projection, WebMercatorProjection } from "./constants/projection.mjs";
7
- import { formatAngle, formatRotation, kmToNauticalMiles, nauticalMilesToKm } from "./utils/distance/index.mjs";
8
- import { createCircleStyle, createStyle, createTextStyle } from "./utils/style/index.mjs";
9
- import { createCircle, createCircleFeature, createFeature, createLineString, createLineStringFeature, createMultiLineString, createMultiLineStringFeature, createMultiPoint, createMultiPointFeature, createMultiPolygon, createMultiPolygonFeature, createPoint, createPointFeature, createPolygon, createPolygonFeature } from "./utils/feature/index.mjs";
10
- import { createBingLayer, createOpenStreetMapLayer, createTianDiTuLayer, createTianDiTuUrl, createVectorLayer, createVectorSource, createWebGLVectorLayer } from "./utils/layer/index.mjs";
11
- import { EPSG_3857ExtentToEPSG_4326, EPSG_3857ToEPSG_4326, EPSG_4326ExtentToEPSG_3857, EPSG_4326ToEPSG_3857, mercatorExtentToWgs84, mercatorToWgs84, wgs84ExtentToMercator, wgs84ToMercator } from "./utils/projection/index.mjs";
12
- import "./utils/index.mjs";
13
- import { useDrawLineString } from "./composables/useDrawLineString/index.mjs";
14
- import { useDrawPolygon } from "./composables/useDrawPolygon/index.mjs";
15
- import { useGraticule } from "./composables/useGraticule/index.mjs";
16
- import { usePointermove } from "./composables/usePointermove/index.mjs";
17
- import { useSwitchBaseLayer } from "./composables/useSwitchBaseLayer/index.mjs";
18
- import "./composables/index.mjs";
19
- 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, createBingLayer, createCircle, createCircleFeature, createCircleStyle, createFeature, createLineString, createLineStringFeature, createMultiLineString, createMultiLineStringFeature, createMultiPoint, createMultiPointFeature, createMultiPolygon, createMultiPolygonFeature, createOpenStreetMapLayer, createPoint, createPointFeature, createPolygon, createPolygonFeature, createStyle, createTextStyle, createTianDiTuLayer, createTianDiTuUrl, createVectorLayer, createVectorSource, createWebGLVectorLayer, formatAngle, formatRotation, kmToNauticalMiles, mercatorExtentToWgs84, mercatorToWgs84, nauticalMilesToKm, olMapInjectionKey, useContextmenu, useDrawLineString, useDrawPolygon, useGraticule, useOlMap, usePointermove, useSwitchBaseLayer, wgs84ExtentToMercator, wgs84ToMercator };
@@ -1,4 +0,0 @@
1
- import { Map as OLMap } from 'ol';
2
- export type { OLMap };
3
- export type ForEachFeatureAtPixelCallbackOptions = Parameters<Parameters<OLMap['forEachFeatureAtPixel']>[1]>;
4
- export type LayerLike = ForEachFeatureAtPixelCallbackOptions[1];
@@ -1,8 +0,0 @@
1
- /** 公里转海里 */
2
- export declare function kmToNauticalMiles(km: number): number;
3
- /** 海里转公里 */
4
- export declare function nauticalMilesToKm(nauticalMiles: number): number;
5
- /** 格式化Rotation */
6
- export declare function formatRotation(rotation: number): number;
7
- /** 格式化角度 */
8
- export declare function formatAngle(angle: number): number;
@@ -1,14 +0,0 @@
1
- import { ONE_NM } from "../../constants/distance.mjs";
2
- function kmToNauticalMiles(i) {
3
- return i * 1e3 / ONE_NM;
4
- }
5
- function nauticalMilesToKm(i) {
6
- return i * ONE_NM / 1e3;
7
- }
8
- function formatRotation(e) {
9
- return e < 0 ? formatRotation(e + 2 * Math.PI) : e > 2 * Math.PI ? formatRotation(e - 2 * Math.PI) : e;
10
- }
11
- function formatAngle(e) {
12
- return e < 0 ? formatAngle(e + 360) : e >= 360 ? formatAngle(e - 360) : e;
13
- }
14
- export { formatAngle, formatRotation, kmToNauticalMiles, nauticalMilesToKm };