tg-map-vue3 3.2.0 → 3.2.1

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,11 +1,11 @@
1
1
  import { type PropType } from 'vue';
2
2
  import { LatLng } from '../../map/lat-lng';
3
+ import type { UnionIcon } from '../../map/map/overlay/icon';
3
4
  import { type MarkerOverlay } from '../../map/map/overlay/marker';
4
- import type { Icon } from '../../map/map/overlay/icon';
5
5
  import TgMarkerClusterer from '../extra/TgMarkerClusterer.vue';
6
- import type TgLabel from './TgLabel.vue';
7
- import type TgInfoWindow from './TgInfoWindow.vue';
8
6
  import type TgInfoBox from './TgInfoBox.vue';
7
+ import type TgInfoWindow from './TgInfoWindow.vue';
8
+ import type TgLabel from './TgLabel.vue';
9
9
  declare const TgMarker: import("vue").DefineComponent<{
10
10
  position: {
11
11
  type: PropType<LatLng>;
@@ -15,7 +15,7 @@ declare const TgMarker: import("vue").DefineComponent<{
15
15
  type: PropType<string>;
16
16
  };
17
17
  icon: {
18
- type: PropType<Icon>;
18
+ type: PropType<UnionIcon>;
19
19
  };
20
20
  clickable: {
21
21
  type: PropType<boolean>;
@@ -157,7 +157,7 @@ declare const TgMarker: import("vue").DefineComponent<{
157
157
  type: PropType<string>;
158
158
  };
159
159
  icon: {
160
- type: PropType<Icon>;
160
+ type: PropType<UnionIcon>;
161
161
  };
162
162
  clickable: {
163
163
  type: PropType<boolean>;
@@ -29,7 +29,7 @@ export declare abstract class PlacesService {
29
29
  export declare class GooglePlacesService extends PlacesService {
30
30
  map: GoogleMap;
31
31
  inner: google.maps.places.PlacesService;
32
- constructor(map: GoogleMap, options: PlaceServiceOptions);
32
+ constructor(map: GoogleMap, _options: PlaceServiceOptions);
33
33
  search(query: string, location?: string | LatLng): Promise<Place[]>;
34
34
  searchInBounds(query: string, bounds: LatLngBounds): Promise<Place[]>;
35
35
  searchNearBy(query: string, center: LatLng, radius: number): Promise<Place[]>;
@@ -40,7 +40,7 @@ export declare class BaiduPlacesService extends PlacesService {
40
40
  private searchRequestMap;
41
41
  get inner(): BMap.LocalSearch;
42
42
  currentSearch: BMap.LocalSearch | undefined;
43
- constructor(map: BaiduMap, options: PlaceServiceOptions);
43
+ constructor(map: BaiduMap, _options: PlaceServiceOptions);
44
44
  search(query: string, location?: string | LatLng): Promise<Place[]>;
45
45
  searchInBounds(query: string, bounds: LatLngBounds): Promise<Place[]>;
46
46
  searchNearBy(query: string, center: LatLng, radius: number): Promise<Place[]>;
@@ -1,7 +1,16 @@
1
1
  /// <reference types="google.maps" />
2
2
  /// <reference types="baidumap-web-sdk" />
3
3
  import type { Point, Size } from '../../types';
4
- /** 字面量形式, 使用起来会简单点, 目前没看出使用class形式的必要🤔 */
4
+ export type UnionIcon = Icon | SymbolIcon;
5
+ export declare const UnionIcon: {
6
+ toGoogle: (icon: UnionIcon) => google.maps.Icon | google.maps.Symbol;
7
+ toBaidu: (icon: UnionIcon) => BMap.Icon | BaiduSymbolIcon;
8
+ };
9
+ /**
10
+ * 图片Icon
11
+ *
12
+ * 字面量形式, 使用起来会简单点, 目前没看出使用class形式的必要🤔
13
+ * */
5
14
  export interface Icon {
6
15
  readonly url: string;
7
16
  readonly size: Size;
@@ -14,3 +23,65 @@ export declare namespace Icon {
14
23
  function toGoogle(icon: Icon): google.maps.Icon;
15
24
  function toBaidu(icon: Icon): BMap.Icon;
16
25
  }
26
+ /** 简单的矢量Icon */
27
+ export interface SymbolIcon {
28
+ readonly path: string | SymbolPath;
29
+ readonly anchor?: Point;
30
+ readonly fillColor?: string;
31
+ /** @default 0, 不显示填充色 */
32
+ readonly fillOpacity?: number;
33
+ readonly scale?: number;
34
+ readonly rotation?: number;
35
+ readonly strokeColor?: string;
36
+ /** @default 1, 显示stroke */
37
+ readonly strokeOpacity?: number;
38
+ readonly strokeWeight?: number;
39
+ /**
40
+ * baidu地图中Marker的Label的偏移量, 用来保证Label默认对齐到Marker的position
41
+ *
42
+ * 这个值的取值和如下参数相关, 但计算这个值的公式没找到...故只能运行时读取+手动设置:
43
+ * - {@link path}
44
+ * - {@link rotation}
45
+ * - {@link scale}
46
+ * - {@link strokeWeight}
47
+ * - {@link anchor}
48
+ *
49
+ * 详见{@link BaiduLabelOverlay.attachIcon}
50
+ */
51
+ readonly baiduLabelOffset?: Point;
52
+ }
53
+ export declare namespace SymbolIcon {
54
+ function toGoogle(icon: SymbolIcon): google.maps.Symbol;
55
+ function toBaidu(icon: SymbolIcon): BaiduSymbolIcon;
56
+ }
57
+ export type BaiduSymbolIcon = BMap.Symbol & {
58
+ __icon__?: SymbolIcon;
59
+ };
60
+ export interface SymbolPath {
61
+ baidu(): BMap.SymbolShapeType;
62
+ google(): google.maps.SymbolPath;
63
+ toString(): string;
64
+ }
65
+ /** 模拟一个SymbolPath的枚举对象 */
66
+ export declare const SymbolPath: {
67
+ readonly CIRCLE: {
68
+ readonly baidu: () => number;
69
+ readonly google: () => google.maps.SymbolPath.CIRCLE;
70
+ };
71
+ readonly BACKWARD_CLOSED_ARROW: {
72
+ readonly baidu: () => number;
73
+ readonly google: () => google.maps.SymbolPath.BACKWARD_CLOSED_ARROW;
74
+ };
75
+ readonly BACKWARD_OPEN_ARROW: {
76
+ readonly baidu: () => number;
77
+ readonly google: () => google.maps.SymbolPath.BACKWARD_OPEN_ARROW;
78
+ };
79
+ readonly FORWARD_CLOSED_ARROW: {
80
+ readonly baidu: () => number;
81
+ readonly google: () => google.maps.SymbolPath.FORWARD_CLOSED_ARROW;
82
+ };
83
+ readonly FORWARD_OPEN_ARROW: {
84
+ readonly baidu: () => number;
85
+ readonly google: () => google.maps.SymbolPath.FORWARD_OPEN_ARROW;
86
+ };
87
+ };
@@ -5,6 +5,7 @@ import { Point } from '../../types';
5
5
  import type { BaiduMap } from '../baidu-map';
6
6
  import type { GoogleMap } from '../google-map';
7
7
  import { type GoogleLabel } from './google-label';
8
+ import type { BaiduSymbolIcon } from './icon';
8
9
  import { BaiduOverlay, GoogleOverlay, Overlay } from './overlay';
9
10
  export type BaiduLabel = BMap.Label & {
10
11
  __label__?: BaiduLabelOverlay;
@@ -61,6 +62,7 @@ declare namespace LabelContent {
61
62
  export declare class BaiduLabelOverlay extends BaiduOverlay<BaiduLabel> implements Label {
62
63
  static create(this: BaiduMap, options: LabelOptions): BaiduLabelOverlay;
63
64
  private icon;
65
+ private iconAnchor;
64
66
  private content;
65
67
  private contentObserver;
66
68
  constructor(innerOverlay: BaiduLabel, coordType: CoordType, map: BaiduMap, content: LabelContent);
@@ -75,7 +77,7 @@ export declare class BaiduLabelOverlay extends BaiduOverlay<BaiduLabel> implemen
75
77
  * 关联新的Icon, 内部使用的方法
76
78
  * @description baidu中Label默认左上角对齐Icon的左上, 我们要将其转换为对齐marker的position
77
79
  * */
78
- attachIcon(icon: BMap.Icon | undefined): void;
80
+ attachIcon(icon: BMap.Icon | BaiduSymbolIcon | undefined): void;
79
81
  }
80
82
  export declare class GoogleLabelOverlay extends GoogleOverlay<GoogleLabel> implements Label {
81
83
  static create(this: GoogleMap, options: LabelOptions): GoogleLabelOverlay;
@@ -1,20 +1,19 @@
1
- /// <reference types="baidumap-web-sdk" />
2
1
  /// <reference types="google.maps" />
3
2
  import type { Nullable } from '../../../utils/mapped-types';
4
3
  import type { Tg } from '../../event';
5
4
  import { CoordType, LatLng } from '../../lat-lng';
6
- import type { UnionIcon } from '../../unions';
5
+ import type { UnionBaiduIcon, UnionGoogleIcon } from '../../unions';
7
6
  import type { BaiduMap } from '../baidu-map';
8
7
  import type { GoogleMap } from '../google-map';
9
8
  import type { AbstractMap } from '../map';
10
9
  import type { BaiduInfoBox } from './baidu-info-box';
11
- import { Icon } from './icon';
10
+ import { UnionIcon } from './icon';
12
11
  import type { BaiduLabelOverlay, GoogleLabelOverlay, LabelOverlay } from './label';
13
12
  import { BaiduOverlay, GoogleOverlay, Overlay, type OverlayOptions } from './overlay';
14
13
  export interface MarkerOptions extends OverlayOptions {
15
14
  position: LatLng;
16
15
  title?: string;
17
- icon?: Icon;
16
+ icon?: UnionIcon;
18
17
  /** @default true */
19
18
  clickable?: boolean;
20
19
  /** @default false */
@@ -51,9 +50,9 @@ export interface Marker extends Tg.EventTargetTyped<Marker, MarkerEventMap> {
51
50
  setPosition(position: LatLng): void;
52
51
  setTitle(title: string): void;
53
52
  getTitle(): string;
54
- setIcon(icon: Icon): void;
55
- /** 感觉并没有读取Icon的必要, 直接返回UnionIcon, 懒得写包装类_(:3」∠)_ */
56
- getIcon(): Nullable<UnionIcon>;
53
+ setIcon(icon: UnionIcon): void;
54
+ /** 感觉并没有读取Icon的必要, 直接返回内部的Icon, 懒得写包装类_(:3」∠)_ */
55
+ getIcon(): Nullable<UnionGoogleIcon | UnionBaiduIcon>;
57
56
  /**
58
57
  * ## 不同行为
59
58
  * - baidu: 不支持设置clickable
@@ -92,8 +91,8 @@ export declare class BaiduMarker extends BaiduOverlay<BMarker> implements Marker
92
91
  setPosition(position: LatLng): void;
93
92
  setTitle(title: string): void;
94
93
  getTitle(): string;
95
- setIcon(icon: Icon): void;
96
- getIcon(): UnionIcon;
94
+ setIcon(icon: UnionIcon): void;
95
+ getIcon(): UnionBaiduIcon;
97
96
  setClickable(enable: boolean): void;
98
97
  isClickable(): boolean;
99
98
  setDraggable(enable: boolean): void;
@@ -113,8 +112,8 @@ export declare class GoogleMarker extends GoogleOverlay<google.maps.Marker> impl
113
112
  setPosition(position: LatLng): void;
114
113
  setTitle(title: string): void;
115
114
  getTitle(): string;
116
- setIcon(icon: Icon): void;
117
- getIcon(): Nullable<UnionIcon>;
115
+ setIcon(icon: UnionIcon): void;
116
+ getIcon(): Nullable<UnionGoogleIcon>;
118
117
  setClickable(flag: boolean): void;
119
118
  isClickable(): boolean;
120
119
  setDraggable(enable: boolean): void;
@@ -8,7 +8,8 @@ import type { GoogleLabel } from './map/overlay/google-label';
8
8
  * Map相关的各种类型的联合, 可以用来简化一部分代码的书写
9
9
  */
10
10
  export type UnionMap = google.maps.Map | BMap.Map | H.Map;
11
- export type UnionIcon = google.maps.Icon | google.maps.Symbol | google.maps.UrlIcon | BMap.Icon;
11
+ export type UnionBaiduIcon = BMap.Icon | BMap.Symbol;
12
+ export type UnionGoogleIcon = google.maps.Icon | google.maps.Symbol | google.maps.UrlIcon;
12
13
  export type UnionInfoWindow = google.maps.InfoWindow | BMap.InfoWindow;
13
14
  export type UnionAutocomplete = google.maps.places.Autocomplete | BMap.Autocomplete;
14
15
  export type UnionPlacesService = google.maps.places.PlacesService | BMap.LocalSearch;
@@ -8,6 +8,10 @@ export declare namespace Objects {
8
8
  function toJsonSafely(value: any): string;
9
9
  /** 删除obj中纯对象上的值为undefined的属性 */
10
10
  function deleteUndefinedPropertyOnPlainObjectDeeply(obj: any): void;
11
+ /** @see Omit */
12
+ function omit<T, K extends keyof any>(obj: T, ...keys: K[]): Omit<T, K>;
13
+ /** @see Pick */
14
+ function pick<T, K extends keyof T>(obj: T, ...keys: K[]): Pick<T, K>;
11
15
  }
12
16
  /** 用于替代Vue2中的filter, 直接交给模板使用 */
13
17
  export declare const stringify: typeof Objects.toJsonSafely;