@summeruse/ol 0.5.0 → 0.6.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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # @summeruse/ol
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 6a8ca7e: feat(composables): 新增 useMapClick 组合式函数处理地图点击事件
8
+
9
+ ### Patch Changes
10
+
11
+ - d727683: feat(usePointermove): 支持 hitTolerance 并按容差分组优化检测性能
12
+
13
+ ## 0.5.1
14
+
15
+ ### Patch Changes
16
+
17
+ - 774051c: feat(utils): 添加弧度与角度转换函数
18
+ - 112feb2: feat(ol-map): 添加地图旋转支持
19
+
3
20
  ## 0.5.0
4
21
 
5
22
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -2,19 +2,19 @@ import * as vue20 from "vue";
2
2
  import { CSSProperties, InjectionKey, MaybeRef, MaybeRefOrGetter, Ref, VNode, VNodeChild } from "vue";
3
3
  import * as ol0 from "ol";
4
4
  import { Feature, Map, Map as OLMap, MapEvent } from "ol";
5
- import { Extent } from "ol/extent";
6
5
  import { Circle, Geometry, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon } from "ol/geom";
7
- import VectorLayer from "ol/layer/Vector";
8
- import VectorSource from "ol/source/Vector";
9
6
  import { Circle as Circle$1, Fill, Icon, Stroke, Style, Text } from "ol/style";
10
7
  import { Graticule, Layer, Tile } from "ol/layer";
11
8
  import HeatmapLayer from "ol/layer/Heatmap";
9
+ import VectorLayer from "ol/layer/Vector";
12
10
  import WebGLVectorLayer from "ol/layer/WebGLVector";
13
11
  import * as ol_source0 from "ol/source";
14
12
  import { BingMaps, OSM, Source, XYZ } from "ol/source";
15
13
  import ImageTileSource from "ol/source/ImageTile";
14
+ import VectorSource from "ol/source/Vector";
16
15
  import { Projection } from "ol/proj";
17
16
  import * as ol_tilegrid0 from "ol/tilegrid";
17
+ import { Extent } from "ol/extent";
18
18
  import * as ol_coordinate0 from "ol/coordinate";
19
19
  import { Coordinate } from "ol/coordinate";
20
20
  import { ObjectEvent } from "ol/Object";
@@ -27,8 +27,12 @@ import * as ol_renderer_Layer0 from "ol/renderer/Layer";
27
27
  import { FrameState } from "ol/Map";
28
28
  import { FlatStyleLike } from "ol/style/flat";
29
29
  import proj4 from "proj4";
30
+ import { Pixel } from "ol/pixel";
30
31
  import TileLayer from "ol/layer/Tile";
31
32
 
33
+ //#region constants/distance.d.ts
34
+ declare const ONE_NM = 1852;
35
+ //#endregion
32
36
  //#region constants/projection.d.ts
33
37
  /** 3857坐标系 球面墨卡托投影坐标系 */
34
38
  declare const EPSG_3857 = "EPSG:3857";
@@ -42,6 +46,7 @@ type ProjectionLike = 'EPSG:3857' | 'EPSG:4326' | 'EPSG:3395';
42
46
  interface OlMapProps {
43
47
  olMap?: Map;
44
48
  center?: Coordinate;
49
+ rotation?: number;
45
50
  zoom?: number;
46
51
  minZoom?: number;
47
52
  maxZoom?: number;
@@ -66,7 +71,9 @@ declare function useOlMap(): Map | undefined;
66
71
  interface OlMapEmits {
67
72
  'update:zoom': [number];
68
73
  'update:center': [Coordinate];
74
+ 'update:rotation': [number];
69
75
  'changeResolution': [ObjectEvent];
76
+ 'changeRotation': [ObjectEvent];
70
77
  'changeCenter': [ObjectEvent];
71
78
  'moveend': [MapEvent];
72
79
  'movestart': [MapEvent];
@@ -85,18 +92,23 @@ declare const __VLS_component: vue20.DefineComponent<OlMapProps, {
85
92
  }, {}, {}, {}, vue20.ComponentOptionsMixin, vue20.ComponentOptionsMixin, {
86
93
  "update:zoom": (args_0: number) => any;
87
94
  "update:center": (args_0: ol_coordinate0.Coordinate) => any;
95
+ "update:rotation": (args_0: number) => any;
88
96
  changeResolution: (args_0: ObjectEvent) => any;
97
+ changeRotation: (args_0: ObjectEvent) => any;
89
98
  changeCenter: (args_0: ObjectEvent) => any;
90
99
  moveend: (args_0: MapEvent) => any;
91
100
  movestart: (args_0: MapEvent) => any;
92
101
  }, string, vue20.PublicProps, Readonly<OlMapProps> & Readonly<{
93
102
  "onUpdate:zoom"?: ((args_0: number) => any) | undefined;
94
103
  "onUpdate:center"?: ((args_0: ol_coordinate0.Coordinate) => any) | undefined;
104
+ "onUpdate:rotation"?: ((args_0: number) => any) | undefined;
95
105
  onChangeResolution?: ((args_0: ObjectEvent) => any) | undefined;
106
+ onChangeRotation?: ((args_0: ObjectEvent) => any) | undefined;
96
107
  onChangeCenter?: ((args_0: ObjectEvent) => any) | undefined;
97
108
  onMoveend?: ((args_0: MapEvent) => any) | undefined;
98
109
  onMovestart?: ((args_0: MapEvent) => any) | undefined;
99
110
  }>, {
111
+ rotation: number;
100
112
  maxZoom: number;
101
113
  minZoom: number;
102
114
  olMap: Map;
@@ -126,6 +138,9 @@ type OlMapInst = InstanceType<typeof _default>;
126
138
  //#region types/index.d.ts
127
139
  type ForEachFeatureAtPixelCallbackOptions = Parameters<Parameters<OLMap['forEachFeatureAtPixel']>[1]>;
128
140
  type LayerLike = ForEachFeatureAtPixelCallbackOptions[1];
141
+ interface Option {
142
+ [key: string]: any;
143
+ }
129
144
  //#endregion
130
145
  //#region composables/useContextmenu/index.d.ts
131
146
  interface ContextmenuPosition {
@@ -200,6 +215,10 @@ type UseContextmenuFn = (...args: UseContextmenuParams) => UseContextmenuReturn;
200
215
  declare function kmToNauticalMiles(km: number): number;
201
216
  /** 海里转公里 */
202
217
  declare function nauticalMilesToKm(nauticalMiles: number): number;
218
+ /** 弧度转角度 */
219
+ declare function rotationToAngle(rotation: number): number;
220
+ /** 角度转弧度 */
221
+ declare function angleToRotation(angle: number): number;
203
222
  /** 格式化Rotation */
204
223
  declare function formatRotation(rotation: number): number;
205
224
  /** 格式化角度 */
@@ -580,6 +599,52 @@ declare function useGraticule(options: UseGraticuleOptions): {
580
599
  };
581
600
  type UseGraticuleReturn = ReturnType<typeof useGraticule>;
582
601
  //#endregion
602
+ //#region composables/useMapClick/index.d.ts
603
+ /** 点击事件类型 */
604
+ type ClickEventType = 'click' | 'dblclick' | 'singleclick';
605
+ /**
606
+ * 点击事件处理的上下文参数
607
+ */
608
+ interface ClickContext {
609
+ map: OLMap;
610
+ coordinate: Coordinate;
611
+ pixel: Pixel;
612
+ feature?: FeatureLike;
613
+ layer: LayerLike;
614
+ }
615
+ /**
616
+ * 点击配置
617
+ */
618
+ type ClickConfig<T extends Option> = {
619
+ /** Hit-detection 容差(css像素) */
620
+ hitTolerance?: number;
621
+ /** 优先级,数字越大越优先 */
622
+ priority?: number;
623
+ /** 是否处理这个点击 */
624
+ visible?: (context: ClickContext) => boolean | undefined | void;
625
+ /** 点击回调 */
626
+ handler: (context: ClickContext) => void;
627
+ } & T;
628
+ type ClickConfigList<T extends Option> = ClickConfig<T>[];
629
+ interface UseClickHandlerOptions<T extends Option = Option> {
630
+ /** 地图实例 */
631
+ mapRef: MaybeRefOrGetter<OLMap | undefined>;
632
+ /** 提示配置列表 */
633
+ items: MaybeRefOrGetter<ClickConfigList<T>>;
634
+ /** 事件类型 */
635
+ type: ClickEventType;
636
+ }
637
+ /**
638
+ * 通用的点击处理 Hook
639
+ */
640
+ declare function useMapClickHandler<T extends Option = Option>(options: UseClickHandlerOptions<T>): void;
641
+ type UseMapClickHandlerReturn = ReturnType<typeof useMapClickHandler>;
642
+ declare function useMapClick<T extends Option = Option>(mapRef: MaybeRefOrGetter<OLMap | undefined>, type: ClickEventType): {
643
+ add: (key: string, items: ClickConfigList<T>) => void;
644
+ remove: (key: string) => void;
645
+ };
646
+ type UseMapClickReturn = ReturnType<typeof useMapClick>;
647
+ //#endregion
583
648
  //#region composables/usePointermove/index.d.ts
584
649
  interface PointermovePosition {
585
650
  x: number;
@@ -590,7 +655,7 @@ interface PointermoveContentParams {
590
655
  coordinate: Coordinate;
591
656
  position: PointermovePosition;
592
657
  feature: FeatureLike;
593
- layer?: LayerLike;
658
+ layer: LayerLike;
594
659
  }
595
660
  type Cursor = CSSProperties['cursor'];
596
661
  type PointermoveItem<T extends Option = Option> = {
@@ -609,11 +674,10 @@ type PointermoveItem<T extends Option = Option> = {
609
674
  cursor?: Cursor | ((params: PointermoveContentParams) => Cursor);
610
675
  /** 固定在feature center 默认启用,若要关闭需要同时开启强制更新 */
611
676
  fixedFeatureCenter?: boolean;
677
+ /** Hit-detection 容差(css像素),用于扩大检测范围 */
678
+ hitTolerance?: number;
612
679
  } & T;
613
680
  type PointermoveList<T extends Option = Option> = PointermoveItem<T>[];
614
- interface Option {
615
- [key: string]: any;
616
- }
617
681
  interface UsePointermoveOptions<T extends Option = Option> {
618
682
  /** 地图实例 */
619
683
  mapRef: MaybeRefOrGetter<OLMap | undefined>;
@@ -662,7 +726,4 @@ declare function useSwitchBaseLayer(data: {
662
726
  visibleLayerName: vue20.Ref<string, string>;
663
727
  };
664
728
  //#endregion
665
- //#region constants/distance.d.ts
666
- declare const ONE_NM = 1852;
667
- //#endregion
668
- export { BingMapsSourceOptions, CanvasLayerOptions, CircleOptions, ContextmenuItem, ContextmenuItemBase, ContextmenuList, ContextmenuOption, ContextmenuOptionBase, ContextmenuOptions, ContextmenuPosition, CreateBingLayerOptions, CreateOpenStreetMapLayerOptions, CreateTianDiTuLayerOptions, CreateTianDiTuUrlOptions, DrawLineStringOptions, DrawPolygonOptions, EPSG_3395, EPSG_3857, EPSG_3857ExtentToEPSG_4326, EPSG_3857ToEPSG_4326, EPSG_4326, EPSG_4326ExtentToEPSG_3857, EPSG_4326ToEPSG_3857, FeatureOptions, FillOptions, GraticuleOptions, HeatmapLayerOptions, IconOptions, ImageTileSourceOptions, ONE_NM, _default as OlMap, OlMapEmits, OlMapInst, OlMapProps, OpenStreetMapSourceOptions, Option, PMTilesLayerOptions, PointermoveItem, PointermoveList, PointermovePosition, ProjectionLike, StrokeOptions, StyleOptions, T_MAP_TYPE, TextOptions, TileLayerOptions, UseContextmenuFn, UseContextmenuParams, UseContextmenuReturn, UseGraticuleOptions, UseGraticuleReturn, UsePointermoveFn, UsePointermoveOptions, UsePointermoveParams, UsePointermoveReturn, VectorLayerOptions, VectorSourceOptions, WebGLVectorLayerOptions, XYZLayerOptions, XYZ_SourceOptions, _CircleOptions, _GraticuleOptions, _StyleOptions, _TextOptions, _VectorLayerOptions, _VectorSourceOptions, _WebGLVectorLayerOptions, createBingLayer, createCanvasLayer, createCircle, createCircleFeature, createCircleStyle, createFeature, createHeatmapLayer, createHeatmapLayerOptions, createLineString, createLineStringFeature, createMultiLineString, createMultiLineStringFeature, createMultiPoint, createMultiPointFeature, createMultiPolygon, createMultiPolygonFeature, createOpenStreetMapLayer, createPMTilesLayer, createPoint, createPointFeature, createPolygon, createPolygonFeature, createStyle, createTextStyle, createTianDiTuLayer, createTianDiTuUrl, createTileGrid, createVectorLayer, createVectorSource, createWebGLVectorLayer, createXYZLayer, formatAngle, formatRotation, kmToNauticalMiles, nauticalMilesToKm, olMapInjectionKey, proj4, registerEPSG_3395, useContextmenu, useDrawLineString, useDrawPolygon, useGraticule, useOlMap, usePointermove, useSwitchBaseLayer };
729
+ export { BingMapsSourceOptions, CanvasLayerOptions, CircleOptions, ClickConfig, ClickConfigList, ClickContext, ClickEventType, ContextmenuItem, ContextmenuItemBase, ContextmenuList, ContextmenuOption, ContextmenuOptionBase, ContextmenuOptions, ContextmenuPosition, CreateBingLayerOptions, CreateOpenStreetMapLayerOptions, CreateTianDiTuLayerOptions, CreateTianDiTuUrlOptions, DrawLineStringOptions, DrawPolygonOptions, EPSG_3395, EPSG_3857, EPSG_3857ExtentToEPSG_4326, EPSG_3857ToEPSG_4326, EPSG_4326, EPSG_4326ExtentToEPSG_3857, EPSG_4326ToEPSG_3857, FeatureOptions, FillOptions, GraticuleOptions, HeatmapLayerOptions, IconOptions, ImageTileSourceOptions, ONE_NM, _default as OlMap, OlMapEmits, OlMapInst, OlMapProps, OpenStreetMapSourceOptions, PMTilesLayerOptions, PointermoveItem, PointermoveList, PointermovePosition, ProjectionLike, StrokeOptions, StyleOptions, T_MAP_TYPE, TextOptions, TileLayerOptions, UseClickHandlerOptions, UseContextmenuFn, UseContextmenuParams, UseContextmenuReturn, UseGraticuleOptions, UseGraticuleReturn, UseMapClickHandlerReturn, UseMapClickReturn, UsePointermoveFn, UsePointermoveOptions, UsePointermoveParams, UsePointermoveReturn, VectorLayerOptions, VectorSourceOptions, WebGLVectorLayerOptions, XYZLayerOptions, XYZ_SourceOptions, _CircleOptions, _GraticuleOptions, _StyleOptions, _TextOptions, _VectorLayerOptions, _VectorSourceOptions, _WebGLVectorLayerOptions, angleToRotation, createBingLayer, createCanvasLayer, createCircle, createCircleFeature, createCircleStyle, createFeature, createHeatmapLayer, createHeatmapLayerOptions, createLineString, createLineStringFeature, createMultiLineString, createMultiLineStringFeature, createMultiPoint, createMultiPointFeature, createMultiPolygon, createMultiPolygonFeature, createOpenStreetMapLayer, createPMTilesLayer, createPoint, createPointFeature, createPolygon, createPolygonFeature, createStyle, createTextStyle, createTianDiTuLayer, createTianDiTuUrl, createTileGrid, createVectorLayer, createVectorSource, createWebGLVectorLayer, createXYZLayer, formatAngle, formatRotation, kmToNauticalMiles, nauticalMilesToKm, olMapInjectionKey, proj4, registerEPSG_3395, rotationToAngle, useContextmenu, useDrawLineString, useDrawPolygon, useGraticule, useMapClick, useMapClickHandler, useOlMap, usePointermove, useSwitchBaseLayer };