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

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.
@@ -1,5 +1,6 @@
1
+ import { MapEvent, Map as OLMap } from 'ol';
2
+ import { ObjectEvent } from 'ol/Object';
1
3
  import { OlMapProps } from './props';
2
- import { Map as OLMap } from 'ol';
3
4
  declare function __VLS_template(): {
4
5
  attrs: Partial<{}>;
5
6
  slots: {
@@ -16,7 +17,21 @@ declare function __VLS_template(): {
16
17
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
17
18
  declare const __VLS_component: import('vue').DefineComponent<OlMapProps, {
18
19
  olMap: OLMap;
19
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<OlMapProps> & Readonly<{}>, {
20
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
21
+ "update:zoom": (args_0: number) => any;
22
+ "update:center": (args_0: import('ol/coordinate').Coordinate) => any;
23
+ changeResolution: (args_0: ObjectEvent) => any;
24
+ changeCenter: (args_0: ObjectEvent) => any;
25
+ moveend: (args_0: MapEvent) => any;
26
+ movestart: (args_0: MapEvent) => any;
27
+ }, string, import('vue').PublicProps, Readonly<OlMapProps> & Readonly<{
28
+ "onUpdate:zoom"?: ((args_0: number) => any) | undefined;
29
+ "onUpdate:center"?: ((args_0: import('ol/coordinate').Coordinate) => any) | undefined;
30
+ onChangeResolution?: ((args_0: ObjectEvent) => any) | undefined;
31
+ onChangeCenter?: ((args_0: ObjectEvent) => any) | undefined;
32
+ onMoveend?: ((args_0: MapEvent) => any) | undefined;
33
+ onMovestart?: ((args_0: MapEvent) => any) | undefined;
34
+ }>, {
20
35
  olMap: OLMap;
21
36
  center: import('ol/coordinate').Coordinate;
22
37
  zoom: number;
@@ -1,5 +1,5 @@
1
1
  import { olMapInjectionKey } from "./props.mjs";
2
- import { createElementBlock, defineComponent, openBlock, provide, ref, renderSlot, unref, watch } from "vue";
2
+ import { createElementBlock, defineComponent, onMounted, onUnmounted, openBlock, provide, ref, renderSlot, unref, watch } from "vue";
3
3
  import { Map, View } from "ol";
4
4
  import { Attribution, FullScreen, OverviewMap, Rotate, ScaleLine, Zoom } from "ol/control";
5
5
  import { DoubleClickZoom, DragPan, DragRotate, KeyboardPan, KeyboardZoom, MouseWheelZoom, PinchRotate, PinchZoom } from "ol/interaction";
@@ -57,57 +57,93 @@ var index_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCo
57
57
  pinchZoom: { type: Boolean },
58
58
  altShiftDragRotate: { type: Boolean }
59
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
60
+ emits: [
61
+ "update:zoom",
62
+ "update:center",
63
+ "changeResolution",
64
+ "changeCenter",
65
+ "moveend",
66
+ "movestart"
67
+ ],
68
+ setup(T, { expose: E, emit: D }) {
69
+ let O = T, k = D, A = ref(), j = O.olMap, M = new View({
70
+ projection: O.projection,
71
+ extent: O.extent
64
72
  });
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);
73
+ j.setView(M), M.setZoom(O.zoom), M.setCenter(O.center), watch(() => O.constrainResolution, (e) => {
74
+ M.setConstrainResolution(e);
75
+ }, { immediate: !0 }), watch(() => O.minZoom, (e) => {
76
+ e && M.setMinZoom(e);
77
+ }, { immediate: !0 }), watch(() => O.maxZoom, (e) => {
78
+ e && M.setMaxZoom(e);
79
+ }, { immediate: !0 }), watch(A, (e) => {
80
+ e && j.setTarget(e);
81
+ }), E({ olMap: j }), provide(olMapInjectionKey, j);
82
+ let N = j.getControls().getArray(), P = N.find((e) => e instanceof Zoom) || new Zoom(), F = N.find((e) => e instanceof Attribution) || new Attribution(), I = N.find((e) => e instanceof Rotate) || new Rotate(), L = N.find((e) => e instanceof FullScreen) || new FullScreen(), R = N.find((e) => e instanceof OverviewMap) || new OverviewMap(), z = N.find((e) => e instanceof ScaleLine) || new ScaleLine();
83
+ watch(() => O.showZoom, (e) => {
84
+ P.setMap(e ? j : null);
85
+ }, { immediate: !0 }), watch(() => O.showAttribution, (e) => {
86
+ F.setMap(e ? j : null);
87
+ }, { immediate: !0 }), watch(() => O.showRotate, (e) => {
88
+ I.setMap(e ? j : null);
89
+ }, { immediate: !0 }), watch(() => O.showFullScreen, (e) => {
90
+ L.setMap(e ? j : null);
91
+ }, { immediate: !0 }), watch(() => O.showOverview, (e) => {
92
+ R.setMap(e ? j : null);
93
+ }, { immediate: !0 }), watch(() => O.showScale, (e) => {
94
+ z.setMap(e ? j : null);
91
95
  }, { 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) => {
96
+ let B = j.getInteractions().getArray(), V = B.find((e) => e instanceof DragPan) || new DragPan(), H = B.find((e) => e instanceof MouseWheelZoom) || new MouseWheelZoom(), U = B.find((e) => e instanceof DoubleClickZoom) || new DoubleClickZoom(), W = B.find((e) => e instanceof PinchRotate) || new PinchRotate(), G = B.find((e) => e instanceof PinchZoom) || new PinchZoom(), K = B.find((e) => e instanceof DragRotate) || new DragRotate(), q = B.find((e) => e instanceof KeyboardPan) || new KeyboardPan(), J = B.find((e) => e instanceof KeyboardZoom) || new KeyboardZoom();
97
+ j.removeInteraction(V), j.addInteraction(V), j.removeInteraction(H), j.addInteraction(H), j.removeInteraction(U), j.addInteraction(U), j.removeInteraction(W), j.addInteraction(W), j.removeInteraction(G), j.addInteraction(G), j.removeInteraction(K), j.addInteraction(K), j.removeInteraction(q), j.removeInteraction(J), watch(() => O.dragPan, (e) => {
102
98
  V.setActive(e);
103
- }, { immediate: !0 }), watch(() => T.altShiftDragRotate, (e) => {
99
+ }, { immediate: !0 }), watch(() => O.mouseWheelZoom, (e) => {
104
100
  H.setActive(e);
105
- }, { immediate: !0 }), (e, C) => (openBlock(), createElementBlock("div", {
101
+ }, { immediate: !0 }), watch(() => O.doubleClickZoom, (e) => {
102
+ U.setActive(e);
103
+ }, { immediate: !0 }), watch(() => O.pinchRotate, (e) => {
104
+ W.setActive(e);
105
+ }, { immediate: !0 }), watch(() => O.pinchZoom, (e) => {
106
+ G.setActive(e);
107
+ }, { immediate: !0 }), watch(() => O.altShiftDragRotate, (e) => {
108
+ K.setActive(e);
109
+ }, { immediate: !0 });
110
+ function Y(e) {
111
+ k("update:zoom", Math.floor(M.getZoom() || 0)), k("changeResolution", e);
112
+ }
113
+ onMounted(() => {
114
+ M.on("change:resolution", Y);
115
+ }), onUnmounted(() => {
116
+ M.un("change:resolution", Y);
117
+ });
118
+ function X(e) {
119
+ k("update:center", M.getCenter() || [0, 0]), k("changeCenter", e);
120
+ }
121
+ onMounted(() => {
122
+ M.on("change:center", X);
123
+ }), onUnmounted(() => {
124
+ M.un("change:center", X);
125
+ });
126
+ function Z(e) {
127
+ k("movestart", e);
128
+ }
129
+ onMounted(() => {
130
+ j.on("movestart", Z);
131
+ }), onUnmounted(() => {
132
+ j.un("movestart", Z);
133
+ });
134
+ function Q(e) {
135
+ k("moveend", e);
136
+ }
137
+ return onMounted(() => {
138
+ j.on("moveend", Q);
139
+ }), onUnmounted(() => {
140
+ j.un("moveend", Q);
141
+ }), (e, T) => (openBlock(), createElementBlock("div", {
106
142
  ref_key: "mapRef",
107
- ref: E
143
+ ref: A
108
144
  }, [renderSlot(e.$slots, "default", {
109
- olMap: unref(D),
110
- mapRef: E.value
145
+ olMap: unref(j),
146
+ mapRef: A.value
111
147
  })], 512));
112
148
  }
113
149
  });
@@ -1,6 +1,7 @@
1
- import { Map as OLMap } from 'ol';
1
+ import { MapEvent, Map as OLMap } from 'ol';
2
2
  import { Coordinate } from 'ol/coordinate';
3
3
  import { Extent } from 'ol/extent';
4
+ import { ObjectEvent } from 'ol/Object';
4
5
  import { InjectionKey } from 'vue';
5
6
  import { ProjectionLike } from '../../constants/projection';
6
7
  export interface OlMapProps {
@@ -27,3 +28,11 @@ export interface OlMapProps {
27
28
  }
28
29
  export declare const olMapInjectionKey: InjectionKey<OLMap>;
29
30
  export declare function useOlMap(): OLMap | undefined;
31
+ export interface OlMapEmits {
32
+ 'update:zoom': [number];
33
+ 'update:center': [Coordinate];
34
+ 'changeResolution': [ObjectEvent];
35
+ 'changeCenter': [ObjectEvent];
36
+ 'moveend': [MapEvent];
37
+ 'movestart': [MapEvent];
38
+ }
@@ -16,9 +16,9 @@ interface PointermoveContentParams {
16
16
  type Cursor = CSSProperties['cursor'];
17
17
  export type PointermoveItem<T extends Option = Option> = {
18
18
  /** 提示内容,支持函数动态生成 */
19
- content: ((params: PointermoveContentParams) => VNodeChild) | string;
19
+ content?: ((params: PointermoveContentParams) => VNodeChild) | string;
20
20
  /** 是否显示提示,可根据 feature 动态判断 */
21
- visible?: ((params: PointermoveContentParams) => boolean) | boolean;
21
+ visible?: ((params: PointermoveContentParams) => boolean | undefined | void) | boolean;
22
22
  /** 位置偏移 */
23
23
  offset?: {
24
24
  x?: number;
@@ -28,14 +28,24 @@ export type PointermoveItem<T extends Option = Option> = {
28
28
  priority?: number;
29
29
  /** 鼠标样式,如 'pointer', 'crosshair', 'move' 等 */
30
30
  cursor?: Cursor | ((params: PointermoveContentParams) => Cursor);
31
- /** 固定在feature center */
31
+ /** 固定在feature center 默认启用,若要关闭需要同时开启强制更新 */
32
32
  fixedFeatureCenter?: boolean;
33
33
  } & T;
34
34
  export type PointermoveList<T extends Option = Option> = PointermoveItem<T>[];
35
35
  export interface Option {
36
36
  [key: string]: any;
37
37
  }
38
- export declare function usePointermove<T extends Option>(mapRef: MaybeRefOrGetter<OLMap | undefined>, items: MaybeRefOrGetter<PointermoveList<T>>): {
38
+ export interface UsePointermoveOptions<T extends Option = Option> {
39
+ /** 地图实例 */
40
+ mapRef: MaybeRefOrGetter<OLMap | undefined>;
41
+ /** 提示配置列表 */
42
+ items: MaybeRefOrGetter<PointermoveList<T>>;
43
+ /** 前置判断条件 */
44
+ enabled?: boolean | (() => boolean | undefined | void);
45
+ /** 强制更新 (开启后,无论 feature 是否变化,都强制更新提示) */
46
+ forceUpdate?: boolean;
47
+ }
48
+ export declare function usePointermove<T extends Option>({ mapRef, items, enabled, forceUpdate }: UsePointermoveOptions<T>): {
39
49
  visible: import('vue').ComputedRef<boolean>;
40
50
  position: import('vue').ComputedRef<{
41
51
  x: number;
@@ -1,35 +1,40 @@
1
1
  import { computed, onBeforeUnmount, ref, toValue, watch } from "vue";
2
2
  import { getCenter } from "ol/extent";
3
- function usePointermove(o, s) {
4
- let c = ref(!1), l = ref({
3
+ function usePointermove({ mapRef: o, items: s, enabled: c = !0, forceUpdate: l = !1 }) {
4
+ let u = ref(!1), d = ref({
5
5
  x: 0,
6
6
  y: 0
7
- }), u = ref(), d = ref(), f = ref({
7
+ }), f = ref(), p = ref(), m = ref({
8
8
  x: 0,
9
9
  y: 0
10
- }), p = ref(), m = ref(), h = computed(() => ({
11
- x: l.value.x + f.value.x,
12
- y: l.value.y + f.value.y
13
- })), g, _ = "";
14
- function v(e) {
15
- let t = toValue(s).filter((t) => {
10
+ }), h = ref(), g = ref(), _ = computed(() => ({
11
+ x: d.value.x + m.value.x,
12
+ y: d.value.y + m.value.y
13
+ })), v = () => typeof c == "function" ? c() : c, y, b, x = "";
14
+ function S(e) {
15
+ let t = toValue(s);
16
+ return t.sort((e, t) => (t.priority ?? 0) - (e.priority ?? 0)), t.find((t) => {
16
17
  let n = t.visible;
17
18
  return typeof n == "function" ? n(e) : n ?? !0;
18
19
  });
19
- return t.length === 0 ? null : t.sort((e, t) => (t.priority ?? 0) - (e.priority ?? 0))[0];
20
20
  }
21
- function y(e) {
22
- if (!g) return;
23
- let t = g.getEventCoordinate(e);
24
- p.value = t;
25
- let n = g.getEventPixel(e), r, i;
26
- if (g.forEachFeatureAtPixel(n, (e, t) => (r = e, i = t, !0)), !r) {
27
- b();
21
+ function C(e) {
22
+ if (!v()) {
23
+ w();
24
+ return;
25
+ }
26
+ if (!y || !b) return;
27
+ let t = y.getEventCoordinate(e);
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();
28
32
  return;
29
33
  }
30
- u.value = r;
34
+ if (!l && f.value && f.value.getId() === r.getId()) return;
35
+ f.value = r;
31
36
  let o = {
32
- map: g,
37
+ map: y,
33
38
  position: {
34
39
  x: e.clientX,
35
40
  y: e.clientY
@@ -37,65 +42,54 @@ function usePointermove(o, s) {
37
42
  coordinate: t,
38
43
  feature: r,
39
44
  layer: i
40
- }, s = v(o);
45
+ }, s = S(o);
41
46
  if (s) {
42
47
  let { content: e, cursor: t, visible: n, fixedFeatureCenter: r, offset: i, priority: a,...o } = s;
43
- m.value = { ...o };
48
+ g.value = { ...o };
44
49
  }
45
50
  if (!s) {
46
- b();
51
+ w();
47
52
  return;
48
53
  }
49
- f.value = {
54
+ m.value = {
50
55
  x: s.offset?.x ?? 0,
51
56
  y: s.offset?.y ?? 0
52
57
  };
53
- let h = s.fixedFeatureCenter ?? !0, y = r.getGeometry();
54
- if (h && y) {
55
- let e = getCenter(y.getExtent()), t = g.getPixelFromCoordinate(e), { top: n, left: r } = g.getViewport().getBoundingClientRect();
56
- l.value.x = t[0] + r, l.value.y = t[1] + n;
57
- } else l.value = {
58
+ let c = l === !1 ? !0 : s.fixedFeatureCenter ?? !0, _ = r.getGeometry();
59
+ if (c && _) {
60
+ let e = getCenter(_.getExtent()), t = y.getPixelFromCoordinate(e), { top: n, left: r } = b.getBoundingClientRect();
61
+ d.value.x = t[0] + r, d.value.y = t[1] + n;
62
+ } else d.value = {
58
63
  x: e.clientX,
59
64
  y: e.clientY
60
65
  };
61
66
  let x = s.content;
62
- d.value = typeof x == "function" ? () => x(o) : x;
63
- let S = s.cursor, C = typeof S == "function" ? S(o) : S;
64
- if (C && g) {
65
- let e = g.getViewport();
66
- _ ||= e.style.cursor, e.style.cursor = C;
67
- }
68
- c.value = !0;
67
+ p.value = typeof x == "function" ? () => x(o) : x;
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;
69
70
  }
70
- function b() {
71
- if (c.value = !1, u.value = void 0, g && _ !== void 0) {
72
- let e = g.getViewport();
73
- e.style.cursor = _, _ = "";
74
- }
71
+ function w() {
72
+ u.value = !1, f.value = void 0, b && b.style.cursor !== x && (b.style.cursor = x);
75
73
  }
76
- function x(e) {
77
- if (!e) return;
78
- let t = e.getViewport();
79
- t.addEventListener("pointermove", y), t.addEventListener("pointerout", b);
74
+ function T(e) {
75
+ e.addEventListener("pointermove", C);
80
76
  }
81
- function S(e) {
82
- if (!e) return;
83
- let t = e.getViewport();
84
- t.removeEventListener("pointermove", y), t.removeEventListener("pointerout", b);
77
+ function E(e) {
78
+ e.removeEventListener("pointermove", C);
85
79
  }
86
80
  return watch(() => toValue(o), (e, t) => {
87
- t !== e && (S(t), x(e), g = e);
81
+ t !== e && (y = e, e && (b = e.getViewport(), E(b), T(b), x = b.style.cursor));
88
82
  }, { immediate: !0 }), onBeforeUnmount(() => {
89
- S(g);
83
+ b && E(b);
90
84
  }), {
91
- visible: computed(() => c.value),
92
- position: computed(() => h.value),
93
- originalPosition: computed(() => l.value),
94
- feature: computed(() => u.value),
95
- content: computed(() => d.value),
96
- coordinate: computed(() => p.value),
97
- option: computed(() => m.value),
98
- hide: b
85
+ visible: computed(() => u.value),
86
+ position: computed(() => _.value),
87
+ originalPosition: computed(() => d.value),
88
+ feature: computed(() => f.value),
89
+ content: computed(() => p.value),
90
+ coordinate: computed(() => h.value),
91
+ option: computed(() => g.value),
92
+ hide: w
99
93
  };
100
94
  }
101
95
  export { usePointermove };
package/es/index.mjs CHANGED
@@ -4,10 +4,10 @@ import "./components/index.mjs";
4
4
  import { useContextmenu } from "./composables/useContextmenu/index.mjs";
5
5
  import { ONE_NM } from "./constants/distance.mjs";
6
6
  import { EPSG_3857, EPSG_4326, WGS84Projection, WebMercatorProjection } from "./constants/projection.mjs";
7
- import { kmToNauticalMiles, nauticalMilesToKm } from "./utils/distance/index.mjs";
7
+ import { formatAngle, formatRotation, kmToNauticalMiles, nauticalMilesToKm } from "./utils/distance/index.mjs";
8
8
  import { createCircleStyle, createStyle, createTextStyle } from "./utils/style/index.mjs";
9
9
  import { createCircle, createCircleFeature, createFeature, createLineString, createLineStringFeature, createMultiLineString, createMultiLineStringFeature, createMultiPoint, createMultiPointFeature, createMultiPolygon, createMultiPolygonFeature, createPoint, createPointFeature, createPolygon, createPolygonFeature } from "./utils/feature/index.mjs";
10
- import { createVectorLayer, getBingLayer, getOSMLayer, getTianDiTuLayer, getTianDiTuUrl } from "./utils/layer/index.mjs";
10
+ import { createBingLayer, createOpenStreetMapLayer, createTianDiTuLayer, createTianDiTuUrl, createVectorLayer } from "./utils/layer/index.mjs";
11
11
  import { EPSG_3857ExtentToEPSG_4326, EPSG_3857ToEPSG_4326, EPSG_4326ExtentToEPSG_3857, EPSG_4326ToEPSG_3857, mercatorExtentToWgs84, mercatorToWgs84, wgs84ExtentToMercator, wgs84ToMercator } from "./utils/projection/index.mjs";
12
12
  import "./utils/index.mjs";
13
13
  import { useDrawLineString } from "./composables/useDrawLineString/index.mjs";
@@ -16,4 +16,4 @@ import { useGraticule } from "./composables/useGraticule/index.mjs";
16
16
  import { usePointermove } from "./composables/usePointermove/index.mjs";
17
17
  import { useSwitchBaseLayer } from "./composables/useSwitchBaseLayer/index.mjs";
18
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, 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 };
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, formatAngle, formatRotation, kmToNauticalMiles, mercatorExtentToWgs84, mercatorToWgs84, nauticalMilesToKm, olMapInjectionKey, useContextmenu, useDrawLineString, useDrawPolygon, useGraticule, useOlMap, usePointermove, useSwitchBaseLayer, wgs84ExtentToMercator, wgs84ToMercator };
@@ -2,3 +2,7 @@
2
2
  export declare function kmToNauticalMiles(km: number): number;
3
3
  /** 海里转公里 */
4
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,8 +1,14 @@
1
1
  import { ONE_NM } from "../../constants/distance.mjs";
2
- function kmToNauticalMiles(n) {
3
- return n * 1e3 / ONE_NM;
2
+ function kmToNauticalMiles(i) {
3
+ return i * 1e3 / ONE_NM;
4
4
  }
5
- function nauticalMilesToKm(n) {
6
- return n * ONE_NM / 1e3;
5
+ function nauticalMilesToKm(i) {
6
+ return i * ONE_NM / 1e3;
7
7
  }
8
- export { kmToNauticalMiles, nauticalMilesToKm };
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 };
@@ -1,5 +1,5 @@
1
- import { kmToNauticalMiles, nauticalMilesToKm } from "./distance/index.mjs";
1
+ import { formatAngle, formatRotation, kmToNauticalMiles, nauticalMilesToKm } from "./distance/index.mjs";
2
2
  import { createCircleStyle, createStyle, createTextStyle } from "./style/index.mjs";
3
3
  import { createCircle, createCircleFeature, createFeature, createLineString, createLineStringFeature, createMultiLineString, createMultiLineStringFeature, createMultiPoint, createMultiPointFeature, createMultiPolygon, createMultiPolygonFeature, createPoint, createPointFeature, createPolygon, createPolygonFeature } from "./feature/index.mjs";
4
- import { createVectorLayer, getBingLayer, getOSMLayer, getTianDiTuLayer, getTianDiTuUrl } from "./layer/index.mjs";
4
+ import { createBingLayer, createOpenStreetMapLayer, createTianDiTuLayer, createTianDiTuUrl, createVectorLayer } from "./layer/index.mjs";
5
5
  import { EPSG_3857ExtentToEPSG_4326, EPSG_3857ToEPSG_4326, EPSG_4326ExtentToEPSG_3857, EPSG_4326ToEPSG_3857, mercatorExtentToWgs84, mercatorToWgs84, wgs84ExtentToMercator, wgs84ToMercator } from "./projection/index.mjs";
@@ -1,36 +1,40 @@
1
+ import { StyleOptions } from '../style';
1
2
  import { Feature } from 'ol';
2
3
  import { Geometry } from 'ol/geom';
3
4
  import { ProjectionLike } from 'ol/proj';
4
- import { StyleOptions } from '../style';
5
5
  import { Tile as TileLayer } from 'ol/layer';
6
6
  import { default as VectorLayer } from 'ol/layer/Vector';
7
7
  import { BingMaps, OSM, XYZ } from 'ol/source';
8
8
  import { default as VectorSource } from 'ol/source/Vector';
9
9
  export type T_MAP_TYPE = 'vec' | 'cva' | 'img' | 'cia' | 'ter' | 'cta' | 'ibo';
10
- export declare function getTianDiTuUrl(data: {
11
- url?: string;
12
- type: T_MAP_TYPE;
13
- projection: ProjectionLike;
14
- key: string;
15
- }): string;
16
- export declare function getTianDiTuLayer(data: {
10
+ export interface CreateTianDiTuUrlOptions {
17
11
  url?: string;
18
- projection: ProjectionLike;
19
- zIndex?: number;
20
12
  key: string;
21
13
  type: T_MAP_TYPE;
22
- className?: string;
23
- }): TileLayer<XYZ>;
24
- export declare function getBingLayer({ name, zIndex, key, className, }: {
14
+ projection?: ProjectionLike;
15
+ }
16
+ export declare function createTianDiTuUrl(data: CreateTianDiTuUrlOptions): string;
17
+ export type TileLayerOptions = Partial<ConstructorParameters<typeof TileLayer>[0]>;
18
+ export type XYZ_SourceOptions = Partial<ConstructorParameters<typeof XYZ>[0]>;
19
+ export type CreateTianDiTuLayerOptions = CreateTianDiTuUrlOptions & {
20
+ layerOptions?: TileLayerOptions;
21
+ sourceOptions?: XYZ_SourceOptions;
22
+ };
23
+ export declare function createTianDiTuLayer(data: CreateTianDiTuLayerOptions): TileLayer<import('ol/source').Tile<import('ol').Tile>>;
24
+ export type BingMapsSourceOptions = Partial<ConstructorParameters<typeof BingMaps>[0]>;
25
+ export interface CreateBingLayerOptions {
25
26
  name: string;
26
- zIndex?: number;
27
27
  key: string;
28
- className?: string;
29
- }): TileLayer<BingMaps>;
30
- export declare function getOSMLayer(data?: {
31
- zIndex?: number;
32
- className?: string;
33
- }): TileLayer<OSM>;
28
+ layerOptions?: TileLayerOptions;
29
+ sourceOptions?: BingMapsSourceOptions;
30
+ }
31
+ export declare function createBingLayer({ name, key, layerOptions, sourceOptions, }: CreateBingLayerOptions): TileLayer<import('ol/source').Tile<import('ol').Tile>>;
32
+ export type OpenStreetMapSourceOptions = Partial<ConstructorParameters<typeof OSM>[0]>;
33
+ export interface CreateOpenStreetMapLayerOptions {
34
+ layerOptions?: TileLayerOptions;
35
+ sourceOptions?: BingMapsSourceOptions;
36
+ }
37
+ export declare function createOpenStreetMapLayer(data?: CreateOpenStreetMapLayerOptions): TileLayer<import('ol/source').Tile<import('ol').Tile>>;
34
38
  export type _VectorLayerOptions = ConstructorParameters<typeof VectorLayer>[0];
35
39
  export type VectorLayerOptions = _VectorLayerOptions & {
36
40
  styleOptions?: StyleOptions;
@@ -4,38 +4,41 @@ import VectorLayer from "ol/layer/Vector";
4
4
  import VectorSource from "ol/source/Vector";
5
5
  import { Tile } from "ol/layer";
6
6
  import { BingMaps, OSM, XYZ } from "ol/source";
7
- function getTianDiTuUrl(e) {
7
+ function createTianDiTuUrl(e) {
8
8
  let { type: c = "img", projection: l = WebMercatorProjection, key: u } = e, d = e.url || "https://t{0-4}.tianditu.gov.cn", f = `&tk=${u}&SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}`;
9
9
  return `${d}/${c}_${l === "EPSG:4326" ? "c" : l === "EPSG:3857" ? "w" : "c"}/wmts?LAYER=${c}${f}`;
10
10
  }
11
- function getTianDiTuLayer(e) {
12
- let { zIndex: s, projection: c, className: l } = e;
11
+ function createTianDiTuLayer(e) {
12
+ let { layerOptions: s, sourceOptions: c,...l } = e;
13
13
  return new Tile({
14
- className: l,
15
14
  source: new XYZ({
16
- url: getTianDiTuUrl(e),
17
- projection: c,
18
- crossOrigin: "Anonymous"
15
+ url: createTianDiTuUrl(l),
16
+ projection: l.projection,
17
+ crossOrigin: "Anonymous",
18
+ ...c
19
19
  }),
20
- zIndex: s
20
+ ...s
21
21
  });
22
22
  }
23
- function getBingLayer({ name: e, zIndex: s, key: c, className: l }) {
23
+ function createBingLayer({ name: e, key: s, layerOptions: c, sourceOptions: l }) {
24
24
  return new Tile({
25
- className: l,
26
25
  source: new BingMaps({
27
- key: c,
26
+ key: s,
28
27
  imagerySet: e,
29
- placeholderTiles: !1
28
+ placeholderTiles: !1,
29
+ ...l
30
30
  }),
31
- zIndex: s
31
+ ...c
32
32
  });
33
33
  }
34
- function getOSMLayer(e) {
34
+ function createOpenStreetMapLayer(e) {
35
+ let { layerOptions: s, sourceOptions: c } = e || {};
35
36
  return new Tile({
36
- className: e?.className,
37
- source: new OSM({ crossOrigin: "Anonymous" }),
38
- zIndex: e?.zIndex
37
+ source: new OSM({
38
+ crossOrigin: "Anonymous",
39
+ ...c
40
+ }),
41
+ ...s
39
42
  });
40
43
  }
41
44
  function createVectorLayer(e) {
@@ -49,4 +52,4 @@ function createVectorLayer(e) {
49
52
  })
50
53
  };
51
54
  }
52
- export { createVectorLayer, getBingLayer, getOSMLayer, getTianDiTuLayer, getTianDiTuUrl };
55
+ export { createBingLayer, createOpenStreetMapLayer, createTianDiTuLayer, createTianDiTuUrl, createVectorLayer };
@@ -1,5 +1,6 @@
1
+ import { MapEvent, Map as OLMap } from 'ol';
2
+ import { ObjectEvent } from 'ol/Object';
1
3
  import { OlMapProps } from './props';
2
- import { Map as OLMap } from 'ol';
3
4
  declare function __VLS_template(): {
4
5
  attrs: Partial<{}>;
5
6
  slots: {
@@ -16,7 +17,21 @@ declare function __VLS_template(): {
16
17
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
17
18
  declare const __VLS_component: import('vue').DefineComponent<OlMapProps, {
18
19
  olMap: OLMap;
19
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<OlMapProps> & Readonly<{}>, {
20
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
21
+ "update:zoom": (args_0: number) => any;
22
+ "update:center": (args_0: import('ol/coordinate').Coordinate) => any;
23
+ changeResolution: (args_0: ObjectEvent) => any;
24
+ changeCenter: (args_0: ObjectEvent) => any;
25
+ moveend: (args_0: MapEvent) => any;
26
+ movestart: (args_0: MapEvent) => any;
27
+ }, string, import('vue').PublicProps, Readonly<OlMapProps> & Readonly<{
28
+ "onUpdate:zoom"?: ((args_0: number) => any) | undefined;
29
+ "onUpdate:center"?: ((args_0: import('ol/coordinate').Coordinate) => any) | undefined;
30
+ onChangeResolution?: ((args_0: ObjectEvent) => any) | undefined;
31
+ onChangeCenter?: ((args_0: ObjectEvent) => any) | undefined;
32
+ onMoveend?: ((args_0: MapEvent) => any) | undefined;
33
+ onMovestart?: ((args_0: MapEvent) => any) | undefined;
34
+ }>, {
20
35
  olMap: OLMap;
21
36
  center: import('ol/coordinate').Coordinate;
22
37
  zoom: number;