tg-map-vue3 3.6.3 → 3.6.5

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
@@ -3,7 +3,9 @@
3
3
  ## 3.6.x
4
4
 
5
5
  - feat: 添加[MapUrls], 支持打开地图网页
6
+ - feat: [LatLng]和[TgMarker]添加`normalize`相关方法/参数, 处理经纬度不合法的问题
6
7
  - fix: 百度地图的覆盖物([BaiduShape])不能隐藏填充/线条颜色的问题
8
+ - perf: [TgLabel]/[TgInfoBox]/[TgInfoWindow]和[TgMarker]不必紧密相邻, 可以放其他组件
7
9
  - ***BREAKING CHANGE***: `placeService` -> `placesService`
8
10
 
9
11
  ## 3.5.x
@@ -47,6 +49,9 @@
47
49
  [TgRectangle]: src/components/overlays/TgRectangle.vue
48
50
  [TgPolygon]: src/components/overlays/TgPolygon.vue
49
51
  [TgPolyline]: src/components/overlays/TgPolyline.vue
52
+ [TgMarker]: src/components/overlays/TgMarker.vue
53
+ [TgInfoBox]: src/components/overlays/TgInfoBox.vue
54
+ [TgInfoWindow]: src/components/overlays/TgInfoWindow.vue
50
55
  [Icon]: src/map/map/overlay/icon.ts#L18 "图标"
51
56
  [SymbolIcon]: src/map/map/overlay/icon.ts#L55 "Svg图标"
52
57
  [PlacesService]: src/map/map/extra/places-service.ts "位置服务"
@@ -55,4 +60,5 @@
55
60
  [SearchBox]: src/map/map/extra/search-box.ts "搜索框"
56
61
  [useTgMapInner]: src/components/map-hooks.ts
57
62
  [LatLngBounds]: src/map/lat-lng.ts#L157
63
+ [LatLng]: src/map/lat-lng.ts#L26
58
64
  [BaiduShape]: src/map/map/overlay/shape.ts#L32
@@ -1,8 +1,8 @@
1
- import { type EventEmits } from '../../utils/vue-utils';
2
1
  import { LatLng } from '../../map/lat-lng';
3
- import { type TgMarkerPublicInstance } from './TgMarker.vue';
4
- import type { InfoBoxOverlay, InfoBoxOptions } from '../../map/map/overlay/info-box';
2
+ import type { InfoBoxOptions, InfoBoxOverlay } from '../../map/map/overlay/info-box';
5
3
  import type { MarkerOverlay } from '../../map/map/overlay/marker';
4
+ import { type EventEmits } from '../../utils/vue-utils';
5
+ import { type TgMarkerPublicInstance } from './TgMarker.vue';
6
6
  type TgInfoBoxEmits = {
7
7
  'update:show': boolean;
8
8
  };
@@ -26,7 +26,7 @@ declare const TgInfoBox: import("vue").DefineComponent<{
26
26
  zIndex: {
27
27
  type: import("vue").PropType<number>;
28
28
  };
29
- 'onUpdate:show': import("vue").Prop<import("../../utils/vue-utils").EventCallback<boolean>>;
29
+ 'onUpdate:show': import("vue").Prop<import("..").EventCallback<boolean>>;
30
30
  }, {
31
31
  attrs: import("vue").ComputedRef<{
32
32
  binds: Record<string, unknown>;
@@ -62,7 +62,7 @@ declare const TgInfoBox: import("vue").DefineComponent<{
62
62
  zIndex: {
63
63
  type: import("vue").PropType<number>;
64
64
  };
65
- 'onUpdate:show': import("vue").Prop<import("../../utils/vue-utils").EventCallback<boolean>>;
65
+ 'onUpdate:show': import("vue").Prop<import("..").EventCallback<boolean>>;
66
66
  }>> & {
67
67
  "onUpdate:show"?: ((event: boolean) => any) | undefined;
68
68
  }, {}, {}>;
@@ -22,7 +22,7 @@ declare const TgInfoWindow: import("vue").DefineComponent<{
22
22
  disableAutoPan: {
23
23
  type: import("vue").PropType<boolean>;
24
24
  };
25
- 'onUpdate:show': import("vue").Prop<import("../../utils/vue-utils").EventCallback<boolean>>;
25
+ 'onUpdate:show': import("vue").Prop<import("..").EventCallback<boolean>>;
26
26
  }, {
27
27
  attrs: import("vue").ComputedRef<{
28
28
  binds: Record<string, unknown>;
@@ -53,12 +53,12 @@ declare const TgInfoWindow: import("vue").DefineComponent<{
53
53
  disableAutoPan: {
54
54
  type: import("vue").PropType<boolean>;
55
55
  };
56
- 'onUpdate:show': import("vue").Prop<import("../../utils/vue-utils").EventCallback<boolean>>;
56
+ 'onUpdate:show': import("vue").Prop<import("..").EventCallback<boolean>>;
57
57
  }>> & {
58
58
  "onUpdate:show"?: ((event: boolean) => any) | undefined;
59
- onCloseclick?: ((event: import("../../map/event").Tg.Event) => any) | undefined;
60
- onOpen?: ((event: import("../../map/event").Tg.Event) => any) | undefined;
61
- onClose?: ((event: import("../../map/event").Tg.Event) => any) | undefined;
59
+ onCloseclick?: ((event: import("..").Tg.Event) => any) | undefined;
60
+ onOpen?: ((event: import("..").Tg.Event) => any) | undefined;
61
+ onClose?: ((event: import("..").Tg.Event) => any) | undefined;
62
62
  }, {}, {}>;
63
63
  type TgInfoWindow = InstanceType<typeof TgInfoWindow>;
64
64
  export default TgInfoWindow;
@@ -15,7 +15,7 @@ declare const TgLabel: import("vue").DefineComponent<{
15
15
  type: import("vue").PropType<number>;
16
16
  };
17
17
  mapPane: {
18
- type: import("vue").PropType<import("../../utils/mapped-types").StringEnumValue<typeof MapPane>>;
18
+ type: import("vue").PropType<import("..").StringEnumValue<typeof MapPane>>;
19
19
  };
20
20
  }, {
21
21
  attrs: import("vue").ComputedRef<{
@@ -42,10 +42,10 @@ declare const TgLabel: import("vue").DefineComponent<{
42
42
  type: import("vue").PropType<number>;
43
43
  };
44
44
  mapPane: {
45
- type: import("vue").PropType<import("../../utils/mapped-types").StringEnumValue<typeof MapPane>>;
45
+ type: import("vue").PropType<import("..").StringEnumValue<typeof MapPane>>;
46
46
  };
47
47
  }>> & {
48
- onClick?: ((event: import("../../map/event").Tg.Event) => any) | undefined;
48
+ onClick?: ((event: import("..").Tg.Event) => any) | undefined;
49
49
  }, {}, {}>;
50
50
  type TgLabel = InstanceType<typeof TgLabel>;
51
51
  export default TgLabel;
@@ -39,6 +39,9 @@ declare const TgMarker: import("vue").DefineComponent<{
39
39
  visible: {
40
40
  type: PropType<boolean>;
41
41
  };
42
+ normalizePositionForBaidu: {
43
+ type: PropType<boolean>;
44
+ };
42
45
  'onUpdate:position': import("vue").Prop<import("../../utils/vue-utils").EventCallback<LatLng>>;
43
46
  }, {
44
47
  attrs: import("vue").ComputedRef<{
@@ -233,6 +236,9 @@ declare const TgMarker: import("vue").DefineComponent<{
233
236
  visible: {
234
237
  type: PropType<boolean>;
235
238
  };
239
+ normalizePositionForBaidu: {
240
+ type: PropType<boolean>;
241
+ };
236
242
  'onUpdate:position': import("vue").Prop<import("../../utils/vue-utils").EventCallback<LatLng>>;
237
243
  }>> & {
238
244
  onClick?: ((event: import("../../map/event").Tg.MouseEvent) => any) | undefined;
@@ -28,6 +28,18 @@ export declare class LatLng {
28
28
  /** 坐标系 */
29
29
  readonly coord: CoordType;
30
30
  static ZERO: LatLng;
31
+ /**
32
+ * {@template latlng_normalize}
33
+ *
34
+ * 对经纬度进行标准化, 参考google的实现
35
+ *
36
+ * ## 行为不一致
37
+ * - google: google.maps.LatLng的构造器会对经纬度进行标准化, 所有点都能正常显示
38
+ * - baidu: BMap.Point的构造器不会对经纬度进行标准化, 超出范围的点显示到(0, 0)位置
39
+ *
40
+ * {@endtemplate}
41
+ */
42
+ static _normalize(lng: number, lat: number): number[];
31
43
  /** @param coord Baidu Map的坐标一般都是bd09 */
32
44
  static fromBaidu(point: BMap.Point, coord: CoordType): LatLng;
33
45
  /** @param coord Google Map的坐标依据地图类型不同是不一样的 */
@@ -49,7 +61,16 @@ export declare class LatLng {
49
61
  coord: CoordType);
50
62
  /** 转换坐标到指定坐标系 */
51
63
  to(coordType: StringEnumValue<typeof CoordType>): LatLng;
52
- toBaidu(coord: CoordType): BMap.Point;
64
+ /**
65
+ * 转换成baidu的经纬度
66
+ * @param normalize 转换时是否进行标准化, 默认false
67
+ * @see _normalize {@macro latlng_normalize}
68
+ */
69
+ toBaidu(coord: CoordType, normalize?: boolean): BMap.Point;
70
+ /**
71
+ * 转换成google的经纬度, 内部会自动进行标准化
72
+ * @see _normalize {@macro latlng_normalize}
73
+ */
53
74
  toGoogle(coord: CoordType): google.maps.LatLng;
54
75
  toHere(coord: CoordType): H.geo.Point;
55
76
  /**
@@ -61,6 +82,11 @@ export declare class LatLng {
61
82
  * @throws 若当前coord和targetCoord相同, 会抛异常, 故请在外部判断
62
83
  */
63
84
  _convert(targetCoord: CoordType): LngLatTuple;
85
+ /**
86
+ * 标准化, 返回合法的坐标点
87
+ * @see _normalize {@macro latlng_normalize}
88
+ */
89
+ normalize(): LatLng;
64
90
  equals(other: LatLng): boolean;
65
91
  toString(): string;
66
92
  }
@@ -1,3 +1,5 @@
1
+ import GMarkerClusterer from '@google/markerclusterer';
2
+ import BMarkerClusterer from 'bmaplib.markerclusterer';
1
3
  import type { Point, Size } from '../../types';
2
4
  import type { BaiduMap } from '../baidu-map';
3
5
  import type { GoogleMap } from '../google-map';
@@ -45,7 +47,7 @@ export interface ClusterIconStyle {
45
47
  */
46
48
  export declare abstract class MarkerClusterer {
47
49
  map: AbstractMap;
48
- inner: any;
50
+ abstract inner: any;
49
51
  constructor(map: AbstractMap);
50
52
  /** baidu/google 拥有相同的函数名 */
51
53
  clearMarkers(): void;
@@ -60,10 +62,12 @@ export declare abstract class MarkerClusterer {
60
62
  abstract recreate(): void;
61
63
  }
62
64
  export declare class BaiduMarkerClusterer extends MarkerClusterer {
65
+ inner: BMarkerClusterer;
63
66
  constructor(map: BaiduMap, options: MarkerClustererOptions);
64
67
  recreate(): void;
65
68
  }
66
69
  export declare class GoogleMarkerClusterer extends MarkerClusterer {
70
+ inner: GMarkerClusterer;
67
71
  constructor(map: GoogleMap, options: MarkerClustererOptions);
68
72
  recreate(): void;
69
73
  }
@@ -12,6 +12,15 @@ import type { BaiduLabelOverlay, GoogleLabelOverlay, LabelOverlay } from './labe
12
12
  import { BaiduOverlay, GoogleOverlay, Overlay, type OverlayOptions } from './overlay';
13
13
  export interface MarkerOptions extends OverlayOptions {
14
14
  position: LatLng;
15
+ /**
16
+ * 执行{@link LatLng.toBaidu}时是否对经纬度进行标准化
17
+ *
18
+ * 因为{@link LatLng.toGoogle}内部是会自动标准化的, 并且LatLng绝大部分情况下是合法的,
19
+ * 所以添加这个参数, 只在使用者认为必要的时候, 执行标准化
20
+ *
21
+ * {@macro latlng_normalize}
22
+ */
23
+ normalizePositionForBaidu?: boolean;
15
24
  title?: string;
16
25
  icon?: UnionIcon;
17
26
  /** @default true */
@@ -88,6 +97,7 @@ export declare class BaiduMarker extends BaiduOverlay<BMarker> implements Marker
88
97
  clickable: boolean;
89
98
  draggable: boolean;
90
99
  zIndex: number | undefined;
100
+ normalize?: boolean;
91
101
  });
92
102
  getPosition(): LatLng;
93
103
  setPosition(position: LatLng): void;
@@ -19,8 +19,6 @@ export declare namespace Arrays {
19
19
  * @see https://stackoverflow.com/questions/56006111/is-it-possible-to-define-a-non-empty-array-type-in-typescript
20
20
  */
21
21
  function isNotEmpty<T>(arr: T[]): arr is [T, ...T[]];
22
- /** @see isNotEmpty */
23
- function isNullOrEmpty<T>(arr: T[] | null | undefined): arr is [] | null | undefined;
24
22
  }
25
23
  export declare namespace MVCArrays {
26
24
  function indexOf<T>(arr: google.maps.MVCArray<T>, item: T): number;
@@ -32,8 +32,18 @@ export declare function typed<T>(t: T): T;
32
32
  export declare function isInstanceOf<T>(obj: any, constructor: Constructor<T>): obj is T;
33
33
  /** @see isInstanceOf */
34
34
  export declare function safeAs<T>(obj: any, constructor: Constructor<T>): T | undefined;
35
+ /** 判断{@link instance}是否是{@link component}的实例 */
36
+ export declare function isComponentByType<C extends Component & AbstractConstructor>(instance: ComponentPublicInstance | null, component: C): instance is InstanceType<C>;
35
37
  /** 安全转换组件类型, 若不能转换会返回`undefined` */
36
38
  export declare function safeAsComponent<C extends Component & AbstractConstructor>(instance: ComponentPublicInstance | null, component: C): InstanceType<C> | undefined;
39
+ /**
40
+ * 查找[startInstance, endComponent)之间的第一个类型为{@link component}的父组件
41
+ * @param component 查找的组件
42
+ * @param startInstance 查找的开始实例, 包含
43
+ * @param endComponent 查找的终止组件, 不包含
44
+ * @returns
45
+ */
46
+ export declare function findAncestorComponentByType<C extends Component & AbstractConstructor>(component: C, startInstance: ComponentPublicInstance | null, endComponent?: Component & AbstractConstructor): InstanceType<C> | undefined;
37
47
  /** {@link NonNullable} 的反义词 */
38
48
  export type Nullable<T> = T | null | undefined;
39
49
  /** T的所有value的联合类型 */