tg-map-vue3 3.0.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.
- package/README.md +109 -0
- package/dist/src/components/TgMap.vue.d.ts +45 -0
- package/dist/src/components/TgMapWidget.vue.d.ts +49 -0
- package/dist/src/components/controls/TgCustomControl.vue.d.ts +16 -0
- package/dist/src/components/controls/TgMapTypeControl.vue.d.ts +14 -0
- package/dist/src/components/controls/TgScaleControl.vue.d.ts +12 -0
- package/dist/src/components/controls/TgZoomControl.vue.d.ts +12 -0
- package/dist/src/components/extra/TgMarkerClusterer.vue.d.ts +48 -0
- package/dist/src/components/index.d.ts +36 -0
- package/dist/src/components/layers/TgTrafficLayer.vue.d.ts +15 -0
- package/dist/src/components/map-mixin.d.ts +22 -0
- package/dist/src/components/overlays/TgCircle.vue.d.ts +21 -0
- package/dist/src/components/overlays/TgElementOverlay.vue.d.ts +30 -0
- package/dist/src/components/overlays/TgInfoBox.vue.d.ts +29 -0
- package/dist/src/components/overlays/TgInfoWindow.vue.d.ts +25 -0
- package/dist/src/components/overlays/TgLabel.vue.d.ts +21 -0
- package/dist/src/components/overlays/TgMarker.vue.d.ts +60 -0
- package/dist/src/components/overlays/TgPolygon.vue.d.ts +20 -0
- package/dist/src/components/overlays/TgPolyline.vue.d.ts +18 -0
- package/dist/src/map/event-target.d.ts +35 -0
- package/dist/src/map/event.d.ts +47 -0
- package/dist/src/map/lat-lng.d.ts +89 -0
- package/dist/src/map/map/baidu-map.d.ts +66 -0
- package/dist/src/map/map/controls/control.d.ts +101 -0
- package/dist/src/map/map/controls/map-type.control.d.ts +30 -0
- package/dist/src/map/map/controls/scale.control.d.ts +15 -0
- package/dist/src/map/map/controls/zoom.control.d.ts +16 -0
- package/dist/src/map/map/extra/marker-clusterer.d.ts +69 -0
- package/dist/src/map/map/google-map.d.ts +68 -0
- package/dist/src/map/map/here-map.d.ts +49 -0
- package/dist/src/map/map/map-options.d.ts +46 -0
- package/dist/src/map/map/map-type.d.ts +113 -0
- package/dist/src/map/map/map.d.ts +129 -0
- package/dist/src/map/map/overlay/baidu-info-box.d.ts +81 -0
- package/dist/src/map/map/overlay/circle.d.ts +42 -0
- package/dist/src/map/map/overlay/element-overlay.d.ts +33 -0
- package/dist/src/map/map/overlay/google-label.d.ts +74 -0
- package/dist/src/map/map/overlay/icon.d.ts +16 -0
- package/dist/src/map/map/overlay/info-box.d.ts +58 -0
- package/dist/src/map/map/overlay/info-window.d.ts +112 -0
- package/dist/src/map/map/overlay/label.d.ts +89 -0
- package/dist/src/map/map/overlay/marker.d.ts +126 -0
- package/dist/src/map/map/overlay/overlay.d.ts +38 -0
- package/dist/src/map/map/overlay/polygon.d.ts +35 -0
- package/dist/src/map/map/overlay/polyline.d.ts +35 -0
- package/dist/src/map/map/overlay/shape.d.ts +48 -0
- package/dist/src/map/map-config.d.ts +14 -0
- package/dist/src/map/map-factory.d.ts +10 -0
- package/dist/src/map/map-loader.d.ts +5 -0
- package/dist/src/map/types.d.ts +17 -0
- package/dist/src/map/unions.d.ts +19 -0
- package/dist/src/utils/arrays.d.ts +10 -0
- package/dist/src/utils/assert.d.ts +9 -0
- package/dist/src/utils/baidu-utils.d.ts +5 -0
- package/dist/src/utils/elements.d.ts +4 -0
- package/dist/src/utils/formatter.d.ts +1 -0
- package/dist/src/utils/here-utils.d.ts +10 -0
- package/dist/src/utils/lifecycle-log.d.ts +14 -0
- package/dist/src/utils/mapped-types.d.ts +60 -0
- package/dist/src/utils/objects.d.ts +13 -0
- package/dist/src/utils/strings.d.ts +9 -0
- package/dist/src/utils/utils.d.ts +9 -0
- package/dist/src/utils/values.d.ts +34 -0
- package/dist/src/utils/vue-utils.d.ts +82 -0
- package/dist/style.css +1 -0
- package/dist/tg-map.js +4871 -0
- package/dist/tg-map.js.map +1 -0
- package/dist/tg-map.umd.cjs +14 -0
- package/dist/tg-map.umd.cjs.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/// <reference types="baidumap-web-sdk" />
|
|
2
|
+
import { BaiduOverlay, Overlay, GoogleOverlay } from './overlay';
|
|
3
|
+
import type { BaiduMap } from '../baidu-map';
|
|
4
|
+
import { LatLng, CoordType } from '../../lat-lng';
|
|
5
|
+
import { Point } from '../../types';
|
|
6
|
+
import type { Tg } from '../../event';
|
|
7
|
+
import type { GoogleMap } from '../google-map';
|
|
8
|
+
import { type GoogleLabel } from './google-label';
|
|
9
|
+
export type BaiduLabel = BMap.Label & {
|
|
10
|
+
__label__?: BaiduLabelOverlay;
|
|
11
|
+
};
|
|
12
|
+
export type LabelEventMap = {
|
|
13
|
+
click: Tg.Event;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* 初始位置, 左上角对齐position
|
|
17
|
+
*/
|
|
18
|
+
export interface LabelOptions {
|
|
19
|
+
content: LabelContent;
|
|
20
|
+
position?: LatLng;
|
|
21
|
+
offset?: Point;
|
|
22
|
+
/**
|
|
23
|
+
* ## 不同行为
|
|
24
|
+
* 当将label添加到marker中时:
|
|
25
|
+
* - baidu: zIndex设置无效, Label的元素的z-index始终为80
|
|
26
|
+
* - google: 依然有效, 但貌似是由于marker元素的opacity:0;的原因, 调整成比marker小的zIndex后, 依然不能位于marker后方...
|
|
27
|
+
* */
|
|
28
|
+
zIndex?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* ## 不同实现
|
|
32
|
+
* - baidu: 有Label类,
|
|
33
|
+
* - 添加到地图上时, 默认左上角对齐position
|
|
34
|
+
* - 添加到marker中时, 默认左上角对齐marker的icon的左上角
|
|
35
|
+
* - 内容只能是string, string可以是html字符串
|
|
36
|
+
* - google: 没有Label类, 我们用OverlayView实现了一个GoogleLabel
|
|
37
|
+
* - 添加到地图上时, 默认左上角对齐position
|
|
38
|
+
* - 没有添加到marker中的功能
|
|
39
|
+
* - 内容是HTMLElement
|
|
40
|
+
*
|
|
41
|
+
* 针对这些不同, 使用了如下方法使它们行为尽量一致:
|
|
42
|
+
* 1. {@link BaiduLabelOverlay.attachIcon}, 让BaiduLabelOverlay关联icon, 使其添加到地图上时也是左上角对齐position
|
|
43
|
+
* 2. {@link GoogleMarker.setLabel}, 让GoogleMarker关联GoogleLabel, 联动它们的显隐/位置, 使其支持添加到marker中
|
|
44
|
+
* 3. {@link BaiduLabelOverlay.setContentInternal}, 将HTMLElement转成string, 并让BaiduLabelOverlay监听HTMLElement的改变, 由于转换成了string, 故里面的事件监听是无效的, 只能使用{@link LabelEventMap}中的事件
|
|
45
|
+
*/
|
|
46
|
+
export interface Label {
|
|
47
|
+
setContent(content: LabelContent): void;
|
|
48
|
+
getPosition(): LatLng;
|
|
49
|
+
setPosition(position: LatLng): void;
|
|
50
|
+
getOffset(): Point;
|
|
51
|
+
setOffset(offset: Point): void;
|
|
52
|
+
setZIndex(zIndex: number): void;
|
|
53
|
+
}
|
|
54
|
+
export type LabelOverlay = Label & Overlay;
|
|
55
|
+
type LabelContent = string | HTMLElement;
|
|
56
|
+
declare namespace LabelContent {
|
|
57
|
+
function toString(content: LabelContent): string;
|
|
58
|
+
function toElement(content: LabelContent): HTMLElement;
|
|
59
|
+
}
|
|
60
|
+
/** 内容只能是固定不变的 */
|
|
61
|
+
export declare class BaiduLabelOverlay extends BaiduOverlay<BaiduLabel> implements Label {
|
|
62
|
+
static create(this: BaiduMap, options: LabelOptions): BaiduLabelOverlay;
|
|
63
|
+
private icon;
|
|
64
|
+
private content;
|
|
65
|
+
private contentObserver;
|
|
66
|
+
constructor(innerOverlay: BaiduLabel, coordType: CoordType, map: BaiduMap, content: LabelContent);
|
|
67
|
+
private setContentInternal;
|
|
68
|
+
setZIndex(zIndex: number): void;
|
|
69
|
+
getPosition(): LatLng;
|
|
70
|
+
setPosition(position: LatLng): void;
|
|
71
|
+
getOffset(): Point;
|
|
72
|
+
setOffset(offset: Point): void;
|
|
73
|
+
setContent(content: LabelContent): void;
|
|
74
|
+
/**
|
|
75
|
+
* 关联新的Icon, 内部使用的方法
|
|
76
|
+
* @description baidu中Label默认左上角对齐Icon的左上, 我们要将其转换为对齐marker的position
|
|
77
|
+
* */
|
|
78
|
+
attachIcon(icon: BMap.Icon | undefined): void;
|
|
79
|
+
}
|
|
80
|
+
export declare class GoogleLabelOverlay extends GoogleOverlay<GoogleLabel> implements Label {
|
|
81
|
+
static create(this: GoogleMap, options: LabelOptions): GoogleLabelOverlay;
|
|
82
|
+
setZIndex(zIndex: number): void;
|
|
83
|
+
setContent(content: LabelContent): void;
|
|
84
|
+
getPosition(): LatLng;
|
|
85
|
+
setPosition(position: LatLng): void;
|
|
86
|
+
getOffset(): Point;
|
|
87
|
+
setOffset(offset: Point): void;
|
|
88
|
+
}
|
|
89
|
+
export {};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/// <reference types="baidumap-web-sdk" />
|
|
2
|
+
/// <reference types="googlemaps" />
|
|
3
|
+
import { LatLng, CoordType } from '../../lat-lng';
|
|
4
|
+
import { BaiduOverlay, GoogleOverlay, Overlay, type OverlayOptions } from './overlay';
|
|
5
|
+
import { Icon } from './icon';
|
|
6
|
+
import type { Nullable } from '../../../utils/mapped-types';
|
|
7
|
+
import type { UnionIcon } from '../../unions';
|
|
8
|
+
import type { AbstractMap } from '../map';
|
|
9
|
+
import type { Tg } from '../../event';
|
|
10
|
+
import type { BaiduMap } from '../baidu-map';
|
|
11
|
+
import type { GoogleMap } from '../google-map';
|
|
12
|
+
import type { BaiduLabelOverlay, LabelOverlay, GoogleLabelOverlay } from './label';
|
|
13
|
+
import type { BaiduInfoBox } from './baidu-info-box';
|
|
14
|
+
export interface MarkerOptions extends OverlayOptions {
|
|
15
|
+
position: LatLng;
|
|
16
|
+
title?: string;
|
|
17
|
+
icon?: Icon;
|
|
18
|
+
/** @default true */
|
|
19
|
+
clickable?: boolean;
|
|
20
|
+
/** @default false */
|
|
21
|
+
draggable?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* 拖拽时是否显示`x`
|
|
24
|
+
* @default true
|
|
25
|
+
* */
|
|
26
|
+
crossOnDrag?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* ## 不同行为
|
|
29
|
+
* - google: 有`cursor` 属性, 作用是hover时改变cursor
|
|
30
|
+
* - baidu: 有`draggingCursor`属性, 作用是拖动时改变cursor
|
|
31
|
+
* @deprecated 不推荐使用
|
|
32
|
+
*/
|
|
33
|
+
cursor?: string;
|
|
34
|
+
zIndex?: number;
|
|
35
|
+
}
|
|
36
|
+
/** 仅仅起到类型声明的作用... */
|
|
37
|
+
type MarkerEventMap = {
|
|
38
|
+
click: Tg.Event;
|
|
39
|
+
dblclick: Tg.MouseEvent;
|
|
40
|
+
rightclick: Tg.Event;
|
|
41
|
+
mousedown: Tg.MouseEvent;
|
|
42
|
+
mouseup: Tg.MouseEvent;
|
|
43
|
+
mouseout: Tg.MouseEvent;
|
|
44
|
+
mouseover: Tg.MouseEvent;
|
|
45
|
+
dragstart: Tg.Event;
|
|
46
|
+
drag: Tg.MouseEvent;
|
|
47
|
+
dragend: Tg.MouseEvent;
|
|
48
|
+
};
|
|
49
|
+
export interface Marker extends Tg.EventTargetTyped<Marker, MarkerEventMap> {
|
|
50
|
+
getPosition(): LatLng;
|
|
51
|
+
setPosition(position: LatLng): void;
|
|
52
|
+
setTitle(title: string): void;
|
|
53
|
+
getTitle(): string;
|
|
54
|
+
setIcon(icon: Icon): void;
|
|
55
|
+
/** 感觉并没有读取Icon的必要, 直接返回UnionIcon, 懒得写包装类_(:3」∠)_ */
|
|
56
|
+
getIcon(): Nullable<UnionIcon>;
|
|
57
|
+
/**
|
|
58
|
+
* ## 不同行为
|
|
59
|
+
* - baidu: 不支持设置clickable
|
|
60
|
+
* - google: 支持
|
|
61
|
+
* @deprecated 不推荐使用
|
|
62
|
+
*/
|
|
63
|
+
setClickable(enable: boolean): void;
|
|
64
|
+
isClickable(): boolean;
|
|
65
|
+
setDraggable(enable: boolean): void;
|
|
66
|
+
isDraggable(): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* ## 不同行为
|
|
69
|
+
* - baidu: 调用该方法无效
|
|
70
|
+
* - google: 有效
|
|
71
|
+
*/
|
|
72
|
+
setZIndex(zIndex?: number): void;
|
|
73
|
+
getZIndex(): number | undefined;
|
|
74
|
+
setLabel(label: LabelOverlay | undefined): void;
|
|
75
|
+
}
|
|
76
|
+
export type MarkerOverlay = Marker & Overlay;
|
|
77
|
+
export type BMarker = BMap.Marker & {
|
|
78
|
+
__info_box__?: BaiduInfoBox;
|
|
79
|
+
};
|
|
80
|
+
export declare class BaiduMarker extends BaiduOverlay<BMarker> implements Marker {
|
|
81
|
+
/** baidu的Marker不支持读/写clickable等属性, 故只能将创建临时的clickable保存在这个state中 */
|
|
82
|
+
private state;
|
|
83
|
+
static create(this: BaiduMap, options: MarkerOptions): BaiduMarker;
|
|
84
|
+
constructor(innerOverlay: BMap.Marker, coordType: CoordType, map: AbstractMap,
|
|
85
|
+
/** baidu的Marker不支持读/写clickable等属性, 故只能将创建临时的clickable保存在这个state中 */
|
|
86
|
+
state: {
|
|
87
|
+
clickable: boolean;
|
|
88
|
+
draggable: boolean;
|
|
89
|
+
zIndex: number | undefined;
|
|
90
|
+
});
|
|
91
|
+
getPosition(): LatLng;
|
|
92
|
+
setPosition(position: LatLng): void;
|
|
93
|
+
setTitle(title: string): void;
|
|
94
|
+
getTitle(): string;
|
|
95
|
+
setIcon(icon: Icon): void;
|
|
96
|
+
getIcon(): UnionIcon;
|
|
97
|
+
setClickable(enable: boolean): void;
|
|
98
|
+
isClickable(): boolean;
|
|
99
|
+
setDraggable(enable: boolean): void;
|
|
100
|
+
isDraggable(): boolean;
|
|
101
|
+
setZIndex(zIndex?: number): void;
|
|
102
|
+
getZIndex(): number | undefined;
|
|
103
|
+
setLabel(label: BaiduLabelOverlay | undefined): void;
|
|
104
|
+
getLabel(): BaiduLabelOverlay | undefined;
|
|
105
|
+
}
|
|
106
|
+
export declare class GoogleMarker extends GoogleOverlay<google.maps.Marker> implements Marker {
|
|
107
|
+
static create(this: GoogleMap, options: MarkerOptions): GoogleMarker;
|
|
108
|
+
private label;
|
|
109
|
+
private labelPositionListener;
|
|
110
|
+
private labelVisibleListener;
|
|
111
|
+
private labelMapChangedListener;
|
|
112
|
+
getPosition(): LatLng;
|
|
113
|
+
setPosition(position: LatLng): void;
|
|
114
|
+
setTitle(title: string): void;
|
|
115
|
+
getTitle(): string;
|
|
116
|
+
setIcon(icon: Icon): void;
|
|
117
|
+
getIcon(): Nullable<UnionIcon>;
|
|
118
|
+
setClickable(flag: boolean): void;
|
|
119
|
+
isClickable(): boolean;
|
|
120
|
+
setDraggable(enable: boolean): void;
|
|
121
|
+
isDraggable(): boolean;
|
|
122
|
+
setZIndex(zIndex?: number): void;
|
|
123
|
+
getZIndex(): number | undefined;
|
|
124
|
+
setLabel(label: GoogleLabelOverlay | undefined): void;
|
|
125
|
+
}
|
|
126
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { CoordType } from '../../lat-lng';
|
|
2
|
+
import type { AbstractMap } from '../map';
|
|
3
|
+
import type { UnionGoogleOverlay, UnionBaiduOverlay } from '../../unions';
|
|
4
|
+
import type { Tg } from '../../event';
|
|
5
|
+
import { AbstractEventTargetDelegate } from '../../event-target';
|
|
6
|
+
export interface OverlayOptions {
|
|
7
|
+
/** @default true */
|
|
8
|
+
visible?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare abstract class Overlay<T = unknown> implements Tg.EventTarget {
|
|
11
|
+
innerOverlay: T;
|
|
12
|
+
/** 用于保存Overlay内部点的坐标, 它的值有可能和map的不同 */
|
|
13
|
+
protected coordType: CoordType;
|
|
14
|
+
protected map: AbstractMap;
|
|
15
|
+
private delegate;
|
|
16
|
+
addEventListener: (type: string, listener: Tg.EventListener) => void;
|
|
17
|
+
removeEventListener: (type: string, listener: Tg.EventListener) => void;
|
|
18
|
+
constructor(innerOverlay: T,
|
|
19
|
+
/** 用于保存Overlay内部点的坐标, 它的值有可能和map的不同 */
|
|
20
|
+
coordType: CoordType, map: AbstractMap, delegate: AbstractEventTargetDelegate);
|
|
21
|
+
remove(): void;
|
|
22
|
+
abstract isVisible(): boolean;
|
|
23
|
+
abstract setVisible(visible: boolean): void;
|
|
24
|
+
}
|
|
25
|
+
export declare class GoogleOverlay<T extends UnionGoogleOverlay = UnionGoogleOverlay> extends Overlay<T> {
|
|
26
|
+
constructor(innerOverlay: T, coordType: CoordType, map: AbstractMap);
|
|
27
|
+
isVisible(): boolean;
|
|
28
|
+
setVisible(visible: boolean): void;
|
|
29
|
+
}
|
|
30
|
+
export declare class BaiduOverlay<T extends UnionBaiduOverlay = UnionBaiduOverlay> extends Overlay<T> {
|
|
31
|
+
constructor(innerOverlay: T, coordType: CoordType, map: AbstractMap);
|
|
32
|
+
/** 仅限内部使用; 设为private时, 生成的d.ts文件中, 方法返回值会变成any, 故改成了public */
|
|
33
|
+
get overlay(): Required<Pick<UnionBaiduOverlay, "show" | "isVisible" | "hide">>;
|
|
34
|
+
isVisible(): boolean;
|
|
35
|
+
setVisible(visible: boolean): void;
|
|
36
|
+
/** 在创建BaiduOverlay时, 设置options.visible, 仅内部使用 */
|
|
37
|
+
visibleOptionInternal(visible: boolean | undefined): this;
|
|
38
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference types="baidumap-web-sdk" />
|
|
2
|
+
/// <reference types="googlemaps" />
|
|
3
|
+
import type { Tg } from '../../event';
|
|
4
|
+
import type { Overlay } from './overlay';
|
|
5
|
+
import { LatLng } from '../../lat-lng';
|
|
6
|
+
import { BaiduShape, GoogleShape, type ShapeOptions, type Shape } from './shape';
|
|
7
|
+
import type { BaiduMap } from '../baidu-map';
|
|
8
|
+
import type { GoogleMap } from '../google-map';
|
|
9
|
+
type PolygonEventMap = {
|
|
10
|
+
click: Tg.Event;
|
|
11
|
+
dblclick: Tg.Event;
|
|
12
|
+
mousedown: Tg.MouseEvent;
|
|
13
|
+
mouseup: Tg.MouseEvent;
|
|
14
|
+
mouseout: Tg.MouseEvent;
|
|
15
|
+
mouseover: Tg.MouseEvent;
|
|
16
|
+
};
|
|
17
|
+
export interface PolygonOptions extends ShapeOptions {
|
|
18
|
+
paths: LatLng[][];
|
|
19
|
+
}
|
|
20
|
+
export interface Polygon extends Tg.EventTargetTyped<Polygon, PolygonEventMap>, Shape {
|
|
21
|
+
getPaths(): LatLng[][];
|
|
22
|
+
setPaths(paths: LatLng[][]): void;
|
|
23
|
+
}
|
|
24
|
+
export type PolygonOverlay = Polygon & Overlay;
|
|
25
|
+
export declare class BaiduPolygon extends BaiduShape<BMap.Polygon> implements Polygon {
|
|
26
|
+
static create(this: BaiduMap, options: PolygonOptions): BaiduPolygon;
|
|
27
|
+
getPaths(): LatLng[][];
|
|
28
|
+
setPaths(paths: LatLng[][]): void;
|
|
29
|
+
}
|
|
30
|
+
export declare class GooglePolygon extends GoogleShape<google.maps.Polygon> implements Polygon {
|
|
31
|
+
static create(this: GoogleMap, options: PolygonOptions): GooglePolygon;
|
|
32
|
+
getPaths(): LatLng[][];
|
|
33
|
+
setPaths(paths: LatLng[][]): void;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference types="baidumap-web-sdk" />
|
|
2
|
+
/// <reference types="googlemaps" />
|
|
3
|
+
import type { Overlay } from './overlay';
|
|
4
|
+
import { LatLng } from '../../lat-lng';
|
|
5
|
+
import type { Tg } from '../../event';
|
|
6
|
+
import type { BaiduMap } from '../baidu-map';
|
|
7
|
+
import type { GoogleMap } from '../google-map';
|
|
8
|
+
import { BaiduShape, GoogleShape, type NotFillableShape, type NotFillableShapeOptions } from './shape';
|
|
9
|
+
type PolylineEventMap = {
|
|
10
|
+
click: Tg.Event;
|
|
11
|
+
dblclick: Tg.Event;
|
|
12
|
+
mousedown: Tg.MouseEvent;
|
|
13
|
+
mouseup: Tg.MouseEvent;
|
|
14
|
+
mouseout: Tg.MouseEvent;
|
|
15
|
+
mouseover: Tg.MouseEvent;
|
|
16
|
+
};
|
|
17
|
+
export interface PolylineOptions extends NotFillableShapeOptions {
|
|
18
|
+
path: LatLng[];
|
|
19
|
+
}
|
|
20
|
+
export interface Polyline extends Tg.EventTargetTyped<Polyline, PolylineEventMap>, NotFillableShape {
|
|
21
|
+
getPath(): LatLng[];
|
|
22
|
+
setPath(path: LatLng[]): void;
|
|
23
|
+
}
|
|
24
|
+
export type PolylineOverlay = Polyline & Overlay;
|
|
25
|
+
export declare class BaiduPolyline extends BaiduShape<BMap.Polyline> implements Polyline {
|
|
26
|
+
static create(this: BaiduMap, options: PolylineOptions): BaiduPolyline;
|
|
27
|
+
getPath(): LatLng[];
|
|
28
|
+
setPath(path: LatLng[]): void;
|
|
29
|
+
}
|
|
30
|
+
export declare class GooglePolyline extends GoogleShape<google.maps.Polyline> implements Polyline {
|
|
31
|
+
static create(this: GoogleMap, options: PolylineOptions): GooglePolyline;
|
|
32
|
+
getPath(): LatLng[];
|
|
33
|
+
setPath(path: LatLng[]): void;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { BaiduOverlay, GoogleOverlay, type OverlayOptions } from './overlay';
|
|
2
|
+
import type { CoordType } from '../../lat-lng';
|
|
3
|
+
import type { BaiduMap } from '../baidu-map';
|
|
4
|
+
import type { UnionBaiduShape, UnionGoogleShape } from '../../unions';
|
|
5
|
+
export interface ShapeOptions extends OverlayOptions {
|
|
6
|
+
clickable?: boolean;
|
|
7
|
+
editable?: boolean;
|
|
8
|
+
strokeColor?: string;
|
|
9
|
+
strokeOpacity?: number;
|
|
10
|
+
strokeWeight?: number;
|
|
11
|
+
fillColor?: string;
|
|
12
|
+
fillOpacity?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface Shape {
|
|
15
|
+
isEditable(): boolean;
|
|
16
|
+
setEditable(editable: boolean): void;
|
|
17
|
+
setStrokeColor(color: string): void;
|
|
18
|
+
setStrokeOpacity(opacity: number): void;
|
|
19
|
+
setStrokeWeight(weight: number): void;
|
|
20
|
+
/** Polyline 没有该方法 */
|
|
21
|
+
setFillColor(color: string): void;
|
|
22
|
+
/** @see setFillColor */
|
|
23
|
+
setFillOpacity(opacity: number): void;
|
|
24
|
+
}
|
|
25
|
+
export type NotFillableShape = Omit<Shape, 'setFillColor' | 'setFillOpacity'>;
|
|
26
|
+
export type NotFillableShapeOptions = Omit<ShapeOptions, 'fillColor' | 'fillOpacity'>;
|
|
27
|
+
export declare abstract class BaiduShape<T extends UnionBaiduShape> extends BaiduOverlay<T> implements Shape {
|
|
28
|
+
private state;
|
|
29
|
+
constructor(innerOverlay: T, coordType: CoordType, map: BaiduMap, state: {
|
|
30
|
+
editable: boolean;
|
|
31
|
+
});
|
|
32
|
+
isEditable(): boolean;
|
|
33
|
+
setEditable(editable: boolean): void;
|
|
34
|
+
setStrokeColor(color: string): void;
|
|
35
|
+
setStrokeOpacity(opacity: number): void;
|
|
36
|
+
setStrokeWeight(weight: number): void;
|
|
37
|
+
setFillColor(color: string): void;
|
|
38
|
+
setFillOpacity(opacity: number): void;
|
|
39
|
+
}
|
|
40
|
+
export declare abstract class GoogleShape<T extends UnionGoogleShape> extends GoogleOverlay<T> implements Shape {
|
|
41
|
+
isEditable(): boolean;
|
|
42
|
+
setEditable(editable: boolean): void;
|
|
43
|
+
setStrokeColor(color: string): void;
|
|
44
|
+
setStrokeOpacity(opacity: number): void;
|
|
45
|
+
setStrokeWeight(weight: number): void;
|
|
46
|
+
setFillColor(color: string): void;
|
|
47
|
+
setFillOpacity(opacity: number): void;
|
|
48
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DeepPartial } from '../utils/mapped-types';
|
|
2
|
+
export interface MapConfig {
|
|
3
|
+
version: string;
|
|
4
|
+
key: string;
|
|
5
|
+
language: string;
|
|
6
|
+
}
|
|
7
|
+
export interface TgMapConfig {
|
|
8
|
+
google: MapConfig;
|
|
9
|
+
baidu: MapConfig;
|
|
10
|
+
here: MapConfig;
|
|
11
|
+
}
|
|
12
|
+
export type PartialTgMapConfig = DeepPartial<TgMapConfig>;
|
|
13
|
+
export declare function getTgMapConfig(): TgMapConfig;
|
|
14
|
+
export declare function setTgMapConfig(config?: PartialTgMapConfig): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AbstractMap } from './map/map';
|
|
2
|
+
import { MapOptions } from './map/map-options';
|
|
3
|
+
export declare enum TgMapType {
|
|
4
|
+
google = "google",
|
|
5
|
+
baidu = "baidu",
|
|
6
|
+
here = "here"
|
|
7
|
+
}
|
|
8
|
+
export declare namespace TgMapFactory {
|
|
9
|
+
function createMap(type: TgMapType, $map: HTMLElement, mapOptions?: Partial<MapOptions>): AbstractMap;
|
|
10
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { MapConfig } from './map-config';
|
|
2
|
+
import { TgMapType } from './map-factory';
|
|
3
|
+
export declare function loadMap(type: TgMapType, config: MapConfig): Promise<unknown>;
|
|
4
|
+
export declare function loadJsonp(url: string, callbackParamName?: string): Promise<unknown>;
|
|
5
|
+
export declare function loadJs(url: string): Promise<unknown>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface Size {
|
|
2
|
+
readonly width: number;
|
|
3
|
+
readonly height: number;
|
|
4
|
+
}
|
|
5
|
+
export interface Point {
|
|
6
|
+
readonly x: number;
|
|
7
|
+
readonly y: number;
|
|
8
|
+
}
|
|
9
|
+
export declare namespace Point {
|
|
10
|
+
const ZERO: Point;
|
|
11
|
+
}
|
|
12
|
+
export interface Padding {
|
|
13
|
+
top: number;
|
|
14
|
+
right: number;
|
|
15
|
+
bottom: number;
|
|
16
|
+
left: number;
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="googlemaps" />
|
|
2
|
+
/// <reference types="heremaps" />
|
|
3
|
+
/// <reference types="baidumap-web-sdk" />
|
|
4
|
+
import type { GoogleLabel } from './map/overlay/google-label';
|
|
5
|
+
import type { BaiduInfoBox } from './map/overlay/baidu-info-box';
|
|
6
|
+
/**
|
|
7
|
+
* Map相关的各种类型的联合, 可以用来简化一部分代码的书写
|
|
8
|
+
*/
|
|
9
|
+
export type UnionMap = google.maps.Map | BMap.Map | H.Map;
|
|
10
|
+
export type UnionIcon = google.maps.Icon | google.maps.Symbol | google.maps.UrlIcon | BMap.Icon;
|
|
11
|
+
export type UnionInfoWindow = google.maps.InfoWindow | BMap.InfoWindow;
|
|
12
|
+
export type UnionGoogleOverlay = google.maps.Marker | google.maps.Polyline | google.maps.Polygon | google.maps.Circle | google.maps.Rectangle | GoogleLabel;
|
|
13
|
+
export type UnionBaiduOverlay = BMap.Marker | BMap.Polyline | BMap.Polygon | BMap.Circle | BMap.Label | BaiduInfoBox;
|
|
14
|
+
export type UnionGoogleEventTarget = google.maps.MVCObject;
|
|
15
|
+
export type UnionBaiduEventTarget = UnionBaiduOverlay | BMap.InfoWindow | BMap.Map;
|
|
16
|
+
export type UnionBaiduShape = BMap.Polyline | BMap.Polygon | BMap.Circle;
|
|
17
|
+
export type UnionGoogleShape = google.maps.Polyline | google.maps.Polygon | google.maps.Circle;
|
|
18
|
+
export type UnionControl = BMap.Control | Node;
|
|
19
|
+
export type GoogleLayer = google.maps.TrafficLayer | google.maps.TransitLayer | google.maps.KmlLayer | google.maps.BicyclingLayer;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="googlemaps" />
|
|
2
|
+
import type { Constructor } from '../components';
|
|
3
|
+
export declare namespace Arrays {
|
|
4
|
+
function remove<T>(arr: T[], item: T): T | undefined;
|
|
5
|
+
function findByType<T>(arr: any[], constructor: Constructor<T>): T | undefined;
|
|
6
|
+
}
|
|
7
|
+
export declare namespace MVCArrays {
|
|
8
|
+
function indexOf<T>(arr: google.maps.MVCArray<T>, item: T): number;
|
|
9
|
+
function remove<T>(arr: google.maps.MVCArray<T>, item: T): T | undefined;
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* typescript 3.7 的新特性[Assertion Functions](https://github.com/microsoft/TypeScript/issues/33352)
|
|
3
|
+
* */
|
|
4
|
+
export declare function assert(condition: any, msg?: string): asserts condition;
|
|
5
|
+
/**
|
|
6
|
+
* 可以用来防止switch时少写case
|
|
7
|
+
* @see https://www.zhihu.com/question/354601204
|
|
8
|
+
*/
|
|
9
|
+
export declare function assertNever(x: never): never;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function dimen(value: string | number | null | undefined): string | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 最新是3.1版, 但@types/heremaps和以前的项目都用的是3.0版, 故当前先用3.0...
|
|
3
|
+
* TODO: 改成使用3.1版实现
|
|
4
|
+
**/
|
|
5
|
+
export declare const HERE_SUPPORTED_VERSIONS: string[];
|
|
6
|
+
/**
|
|
7
|
+
* 当前@types/heremaps是v3.0版, 和v3.1版api有区别, 若要使用3.1版, 需要用这个方法来做到类型注解兼容...
|
|
8
|
+
* @see https://developer.here.com/documentation/maps/topics/migration.html
|
|
9
|
+
*/
|
|
10
|
+
export declare function ensureHereV31(): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type App } from './@vue/compat';
|
|
2
|
+
import type { VueHookName } from './vue-utils';
|
|
3
|
+
export interface LifecycleLogOptions {
|
|
4
|
+
/** @default /^[A-Z]/ 匹配大写字母开头的组件名 */
|
|
5
|
+
nameRegex?: RegExp;
|
|
6
|
+
/** @default true 开启log */
|
|
7
|
+
enable?: boolean;
|
|
8
|
+
/** @default >> 除 updated, beforeUpdate 外的所有hook */
|
|
9
|
+
hookNames?: VueHookName[];
|
|
10
|
+
}
|
|
11
|
+
declare const LifecycleLogPlugin: {
|
|
12
|
+
install(app: App, options?: LifecycleLogOptions): void;
|
|
13
|
+
};
|
|
14
|
+
export default LifecycleLogPlugin;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Component, ComponentPublicInstance } from './@vue/compat';
|
|
2
|
+
/** deep版的 `Partial` */
|
|
3
|
+
export type DeepPartial<T> = {
|
|
4
|
+
[U in keyof T]?: T[U] extends object ? DeepPartial<T[U]> : T[U];
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* 表示一个构造器
|
|
8
|
+
* {@link import('./@vue/compat/types/options').Constructor}
|
|
9
|
+
* */
|
|
10
|
+
export type Constructor<T = {}> = new (...args: any[]) => T;
|
|
11
|
+
/**
|
|
12
|
+
* 抽象构造器类型, 相比{@link Constructor}, 不能直接用new创建对象
|
|
13
|
+
* @see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-2.html#abstract-construct-signatures
|
|
14
|
+
*/
|
|
15
|
+
export type AbstractConstructor<T = {}> = abstract new (...args: any[]) => T;
|
|
16
|
+
/** 原始类型=>包装类型 */
|
|
17
|
+
export type PrimitiveToWrapper<T> = T extends boolean ? Boolean : T extends string ? String : T extends number ? Number : T;
|
|
18
|
+
/** 包装类型=>原始类型 */
|
|
19
|
+
export type WrapperToPrimitive<T> = T extends Boolean ? boolean : T extends String ? string : T extends Number ? number : T;
|
|
20
|
+
/**
|
|
21
|
+
* 返回undefined但类型是指定的泛型T, 需要你自身保证在使用前先初始化
|
|
22
|
+
* 模仿了kotlin的lateinit关键字
|
|
23
|
+
* */
|
|
24
|
+
export declare function lateinit<T>(): T;
|
|
25
|
+
/** 用来给纯对象的成员加上类型验证 */
|
|
26
|
+
export declare function typed<T>(t: T): T;
|
|
27
|
+
/**
|
|
28
|
+
* `vue instanceof VueConstructor`时`vue`并不会自动转换成`VueConstructor`的子类, 用该方法可以实现这种转换
|
|
29
|
+
*/
|
|
30
|
+
export declare function isInstanceOf<T>(obj: any, constructor: Constructor<T>): obj is T;
|
|
31
|
+
/** @see isInstanceOf */
|
|
32
|
+
export declare function safeAs<T>(obj: any, constructor: Constructor<T>): T | undefined;
|
|
33
|
+
/** 安全转换组件类型, 若不能转换会返回`undefined` */
|
|
34
|
+
export declare function safeAsComponent<C extends Component & AbstractConstructor>(instance: ComponentPublicInstance | null, component: C): InstanceType<C> | undefined;
|
|
35
|
+
/** {@link NonNullable} 的反义词 */
|
|
36
|
+
export type Nullable<T> = T | null | undefined;
|
|
37
|
+
/** T的所有value的联合类型 */
|
|
38
|
+
export type ValueOf<T> = T[keyof T];
|
|
39
|
+
/**
|
|
40
|
+
* 提取出T中value为V的子类的所有key
|
|
41
|
+
* @see https://stackoverflow.com/questions/54520676/in-typescript-how-to-specify-only-keys-of-a-generic-object-whose-values-are-stri
|
|
42
|
+
* */
|
|
43
|
+
export type KeysMatching<T, V> = {
|
|
44
|
+
[K in keyof T]: T[K] extends V ? K : never;
|
|
45
|
+
}[keyof T];
|
|
46
|
+
/**
|
|
47
|
+
* 并不存在可以精确表示一个枚举类型, 该类只能近似表示一个字符枚举
|
|
48
|
+
* */
|
|
49
|
+
export type StringEnumLike = {
|
|
50
|
+
[k: string]: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* 非空的值
|
|
54
|
+
* @see https://github.com/microsoft/TypeScript/issues/7648#issuecomment-541625573
|
|
55
|
+
*/
|
|
56
|
+
export type Thing = string | number | boolean | bigint | object | symbol;
|
|
57
|
+
/** 除T指定的类型外, 其他参数 */
|
|
58
|
+
export type TypedAny<T> = T & {
|
|
59
|
+
[k: string]: any;
|
|
60
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare namespace Objects {
|
|
2
|
+
function fromArray<T>(arr: T[], keySelector: (it: T) => string): {
|
|
3
|
+
[key: string]: T;
|
|
4
|
+
};
|
|
5
|
+
function fromEntries<V>(entries: [string, V][]): {
|
|
6
|
+
[k: string]: V;
|
|
7
|
+
};
|
|
8
|
+
function toJsonSafely(value: any): string;
|
|
9
|
+
/** 删除obj中纯对象上的值为undefined的属性 */
|
|
10
|
+
function deleteUndefinedPropertyOnPlainObjectDeeply(obj: any): void;
|
|
11
|
+
}
|
|
12
|
+
/** 用于替代Vue2中的filter, 直接交给模板使用 */
|
|
13
|
+
export declare const stringify: typeof Objects.toJsonSafely;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { StringEnumLike } from './mapped-types';
|
|
2
|
+
export declare namespace Strings {
|
|
3
|
+
/**
|
|
4
|
+
* 将string转换成字符枚举, 转换失败返回undefined
|
|
5
|
+
* @see import('./vue-utils.ts').stringEnumProp 由于使用了Object.values(enumObject), 应该避免在enumObject上添加其他属性/方法
|
|
6
|
+
*/
|
|
7
|
+
function toEnumOrNull<E extends StringEnumLike>(value: string | undefined, enumObject: E): E[keyof E] | undefined;
|
|
8
|
+
function trimIndent(str: string): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** 抛异常是语句不是表达式, 使用该方法替换则可以在表达式中使用 */
|
|
2
|
+
export declare function throwError(msg?: string): never;
|
|
3
|
+
export declare function throwUnsupported(msg?: string): never;
|
|
4
|
+
export declare function todo(msg?: string): never;
|
|
5
|
+
export declare function debug(msg?: any): any;
|
|
6
|
+
/** 啥也不做 */
|
|
7
|
+
export declare function noop(...args: any[]): void;
|
|
8
|
+
/** 可以用在Array.filter(isDef)中, 用来过滤为空的值 */
|
|
9
|
+
export declare function isDef<T>(v: T | undefined | null): v is T;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** 键值对 */
|
|
2
|
+
export declare class KeyValue<K, V> {
|
|
3
|
+
private keyToValue;
|
|
4
|
+
private valueToKey;
|
|
5
|
+
/**
|
|
6
|
+
* `keys`和`values`数组中可以有相同的值, 若存在相同值, 则index越小的优先级越高
|
|
7
|
+
*/
|
|
8
|
+
constructor(keys: K[], values: V[]);
|
|
9
|
+
toKey(value: V): K;
|
|
10
|
+
toValue(key: K): V;
|
|
11
|
+
}
|
|
12
|
+
export type KeySelector<T, K> = (this: T) => K;
|
|
13
|
+
/** 用key快速查找元素的数组 */
|
|
14
|
+
export declare class FastFindValues<T> {
|
|
15
|
+
values: readonly T[];
|
|
16
|
+
private maxSize4Debug;
|
|
17
|
+
private map;
|
|
18
|
+
constructor(values: readonly T[], maxSize4Debug?: number);
|
|
19
|
+
/** 获取保存key-value映射的Map */
|
|
20
|
+
getValueMap<K>(keySelector: KeySelector<T, K>): Map<K, T>;
|
|
21
|
+
/**
|
|
22
|
+
* 直接用key获取value
|
|
23
|
+
* @param keySelector 从T中读取key的方法, 会用它当key, 缓存结果, 故多次调用需要使用相同的keySelector对象, 不要每次创建新的, 推荐直接使用T.prototype.getXxx作为keySelector
|
|
24
|
+
*/
|
|
25
|
+
getOrNull<K>(keySelector: KeySelector<T, K>, key: K): T | undefined;
|
|
26
|
+
get<K>(keySelector: KeySelector<T, K>, key: K): T;
|
|
27
|
+
}
|
|
28
|
+
/** 缓存的值 */
|
|
29
|
+
export declare class CachedValue<T> {
|
|
30
|
+
private creator;
|
|
31
|
+
private value;
|
|
32
|
+
constructor(creator: () => T);
|
|
33
|
+
get(): T;
|
|
34
|
+
}
|