tg-map-vue3 3.9.5 → 3.9.6
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 +1 -0
- package/dist/src/components/overlays/TgMarker.vue.d.ts +8 -1
- package/dist/src/map/map/overlay/icon.d.ts +11 -5
- package/dist/src/map/map/overlay/label.d.ts +7 -2
- package/dist/src/map/map/overlay/marker-label.d.ts +19 -0
- package/dist/src/map/map/overlay/marker.d.ts +12 -4
- package/dist/tg-map.cjs +6 -6
- package/dist/tg-map.cjs.map +1 -1
- package/dist/tg-map.js +773 -730
- package/dist/tg-map.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,7 @@ import { type PropType } from 'vue';
|
|
|
2
2
|
import { LatLng } from '../../map/lat-lng';
|
|
3
3
|
import type { UnionIcon } from '../../map/map/overlay/icon';
|
|
4
4
|
import { type MarkerEventMap, type MarkerOverlay } from '../../map/map/overlay/marker';
|
|
5
|
+
import type { MarkerLabel } from '../../map/map/overlay/marker-label';
|
|
5
6
|
import { type EventEmits } from '../../utils/vue-utils';
|
|
6
7
|
import TgMarkerClusterer from '../extra/TgMarkerClusterer.vue';
|
|
7
8
|
import type TgInfoBox from './TgInfoBox.vue';
|
|
@@ -18,6 +19,9 @@ declare const TgMarker: import("vue").DefineComponent<{
|
|
|
18
19
|
title: {
|
|
19
20
|
type: PropType<string>;
|
|
20
21
|
};
|
|
22
|
+
label: {
|
|
23
|
+
type: PropType<MarkerLabel>;
|
|
24
|
+
};
|
|
21
25
|
icon: {
|
|
22
26
|
type: PropType<UnionIcon>;
|
|
23
27
|
};
|
|
@@ -58,7 +62,7 @@ declare const TgMarker: import("vue").DefineComponent<{
|
|
|
58
62
|
listenerProps: Record<string, unknown>;
|
|
59
63
|
}>;
|
|
60
64
|
marker: MarkerOverlay;
|
|
61
|
-
|
|
65
|
+
labelOverlay: import("vue").CreateComponentPublicInstance<Readonly<import("vue").ExtractPropTypes<{
|
|
62
66
|
position: {
|
|
63
67
|
type: PropType<LatLng>;
|
|
64
68
|
};
|
|
@@ -168,6 +172,9 @@ declare const TgMarker: import("vue").DefineComponent<{
|
|
|
168
172
|
title: {
|
|
169
173
|
type: PropType<string>;
|
|
170
174
|
};
|
|
175
|
+
label: {
|
|
176
|
+
type: PropType<MarkerLabel>;
|
|
177
|
+
};
|
|
171
178
|
icon: {
|
|
172
179
|
type: PropType<UnionIcon>;
|
|
173
180
|
};
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import type { Point, Size } from '../../types';
|
|
2
|
+
export type BaiduIcon = BMap.Icon & {
|
|
3
|
+
__icon__?: Icon;
|
|
4
|
+
};
|
|
5
|
+
export type BaiduSymbolIcon = BMap.Symbol & {
|
|
6
|
+
__icon__?: SymbolIcon;
|
|
7
|
+
};
|
|
8
|
+
export type BaiduUnionIcon = BaiduIcon | BaiduSymbolIcon;
|
|
2
9
|
export type UnionIcon = Icon | SymbolIcon;
|
|
3
10
|
export declare const UnionIcon: {
|
|
4
11
|
toGoogle: (icon: UnionIcon) => google.maps.Icon | google.maps.Symbol;
|
|
5
|
-
toBaidu: (icon: UnionIcon) =>
|
|
12
|
+
toBaidu: (icon: UnionIcon) => BaiduIcon | BaiduSymbolIcon;
|
|
6
13
|
};
|
|
7
14
|
/**
|
|
8
15
|
* 图片Icon
|
|
@@ -19,10 +26,12 @@ export interface Icon {
|
|
|
19
26
|
readonly anchor?: Point;
|
|
20
27
|
/** 缩放后的图片大小, 不传则不缩放 */
|
|
21
28
|
readonly scaledSize?: Size;
|
|
29
|
+
/** MarkerLabel的中心点相对图标左上角的坐标, 默认为图标的中心点 */
|
|
30
|
+
readonly labelOrigin?: Point;
|
|
22
31
|
}
|
|
23
32
|
export declare namespace Icon {
|
|
24
33
|
function toGoogle(icon: Icon): google.maps.Icon;
|
|
25
|
-
function toBaidu(icon: Icon):
|
|
34
|
+
function toBaidu(icon: Icon): BaiduIcon;
|
|
26
35
|
}
|
|
27
36
|
/** 简单的矢量Icon */
|
|
28
37
|
export interface SymbolIcon {
|
|
@@ -62,9 +71,6 @@ export declare namespace SymbolIcon {
|
|
|
62
71
|
function toGoogle(icon: SymbolIcon): google.maps.Symbol;
|
|
63
72
|
function toBaidu(icon: SymbolIcon): BaiduSymbolIcon;
|
|
64
73
|
}
|
|
65
|
-
export type BaiduSymbolIcon = BMap.Symbol & {
|
|
66
|
-
__icon__?: SymbolIcon;
|
|
67
|
-
};
|
|
68
74
|
export interface SymbolPath {
|
|
69
75
|
baidu(): BMap.SymbolShapeType;
|
|
70
76
|
google(): google.maps.SymbolPath;
|
|
@@ -5,7 +5,7 @@ import type { BaiduMap } from '../baidu-map';
|
|
|
5
5
|
import type { GoogleMap } from '../google-map';
|
|
6
6
|
import { MapPane } from './element-overlay';
|
|
7
7
|
import { type GoogleLabel } from './google-label';
|
|
8
|
-
import type {
|
|
8
|
+
import type { BaiduUnionIcon } from './icon';
|
|
9
9
|
import { BaiduOverlay, GoogleOverlay, Overlay } from './overlay';
|
|
10
10
|
export type BaiduLabel = BMap.Label & {
|
|
11
11
|
__label__?: BaiduLabelOverlay;
|
|
@@ -49,6 +49,11 @@ export interface LabelOptions {
|
|
|
49
49
|
* 1. {@link BaiduLabelOverlay.attachIcon}, 让BaiduLabelOverlay关联icon, 使其添加到地图上时也是左上角对齐position
|
|
50
50
|
* 2. {@link GoogleMarker.setLabel}, 让GoogleMarker关联GoogleLabel, 联动它们的显隐/位置, 使其支持添加到marker中
|
|
51
51
|
* 3. {@link BaiduLabelOverlay.setContentInternal}, 将HTMLElement转成string, 并让BaiduLabelOverlay监听HTMLElement的改变, 由于转换成了string, 故里面的事件监听是无效的, 只能使用{@link LabelEventMap}中的事件
|
|
52
|
+
*
|
|
53
|
+
* ## 后续
|
|
54
|
+
* 经过重新调研, baidu和google是有基本上一致行为的`label`API的, 我们将它抽象成了{@link MarkerLabel}, 对于显示少量文字的情况, 用它就够了
|
|
55
|
+
* 对于显示复杂布局的情况, 当前baidu的实现是通过html转string再转html, 效率可能有问题
|
|
56
|
+
* TODO: 考虑重构成类似google那种基于自定义Overlay的实现方式🤔️
|
|
52
57
|
*/
|
|
53
58
|
export interface Label {
|
|
54
59
|
setContent(content: LabelContent): void;
|
|
@@ -83,7 +88,7 @@ export declare class BaiduLabelOverlay extends BaiduOverlay<BaiduLabel> implemen
|
|
|
83
88
|
* 关联新的Icon, 内部使用的方法
|
|
84
89
|
* @description baidu中Label默认左上角对齐Icon的左上, 我们要将其转换为对齐marker的position
|
|
85
90
|
* */
|
|
86
|
-
attachIcon(icon:
|
|
91
|
+
attachIcon(icon: BaiduUnionIcon | undefined): void;
|
|
87
92
|
}
|
|
88
93
|
export declare class GoogleLabelOverlay extends GoogleOverlay<GoogleLabel> implements Label {
|
|
89
94
|
static create(this: GoogleMap, options: LabelOptions): GoogleLabelOverlay;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import './marker-label.scss';
|
|
2
|
+
/**
|
|
3
|
+
* 和Marker关联的标签
|
|
4
|
+
*
|
|
5
|
+
* 与{@link Label}不同, 该类在google和baidu上都是使用Marker原生的label功能实现的, 更简单
|
|
6
|
+
* 当前baidu的{@link BaiduLabelOverlay}底层也是基于Marker的label, 故和该功能有冲突, 不能同时使用
|
|
7
|
+
*/
|
|
8
|
+
export interface MarkerLabel {
|
|
9
|
+
text: string;
|
|
10
|
+
className?: string;
|
|
11
|
+
color?: string;
|
|
12
|
+
fontSize?: string;
|
|
13
|
+
fontWeight?: string;
|
|
14
|
+
fontFamily?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const MarkerLabel: {
|
|
17
|
+
toBaidu: (label: MarkerLabel) => BMap.Label;
|
|
18
|
+
toGoogle: (label: MarkerLabel) => google.maps.MarkerLabel;
|
|
19
|
+
};
|
|
@@ -7,6 +7,7 @@ import type { GoogleMap } from '../google-map';
|
|
|
7
7
|
import type { BaiduInfoBox } from './baidu-info-box';
|
|
8
8
|
import { UnionIcon } from './icon';
|
|
9
9
|
import type { BaiduLabelOverlay, GoogleLabelOverlay, LabelOverlay } from './label';
|
|
10
|
+
import { MarkerLabel } from './marker-label';
|
|
10
11
|
import { BaiduOverlay, GoogleOverlay, Overlay, type OverlayOptions } from './overlay';
|
|
11
12
|
export interface MarkerOptions extends OverlayOptions {
|
|
12
13
|
position: LatLng;
|
|
@@ -20,6 +21,8 @@ export interface MarkerOptions extends OverlayOptions {
|
|
|
20
21
|
*/
|
|
21
22
|
normalizePositionForBaidu?: boolean;
|
|
22
23
|
title?: string;
|
|
24
|
+
/** @see MarkerLabel */
|
|
25
|
+
label?: MarkerLabel;
|
|
23
26
|
icon?: UnionIcon;
|
|
24
27
|
/** @default true */
|
|
25
28
|
clickable?: boolean;
|
|
@@ -59,6 +62,8 @@ export interface Marker extends Tg.EventTargetTyped<Marker, MarkerEventMap> {
|
|
|
59
62
|
setPosition(position: LatLng): void;
|
|
60
63
|
setTitle(title: string): void;
|
|
61
64
|
getTitle(): string;
|
|
65
|
+
/** @see MarkerLabel */
|
|
66
|
+
setLabel(label: MarkerLabel): void;
|
|
62
67
|
setIcon(icon: UnionIcon): void;
|
|
63
68
|
/** 感觉并没有读取Icon的必要, 直接返回内部的Icon, 懒得写包装类_(:3」∠)_ */
|
|
64
69
|
getIcon(): Nullable<UnionGoogleIcon | UnionBaiduIcon>;
|
|
@@ -79,7 +84,7 @@ export interface Marker extends Tg.EventTargetTyped<Marker, MarkerEventMap> {
|
|
|
79
84
|
*/
|
|
80
85
|
setZIndex(zIndex?: number): void;
|
|
81
86
|
getZIndex(): number | undefined;
|
|
82
|
-
|
|
87
|
+
attachLabelOverlay(label: LabelOverlay | undefined): void;
|
|
83
88
|
}
|
|
84
89
|
export type MarkerOverlay = Marker & Overlay;
|
|
85
90
|
export type BMarker = BMap.Marker & {
|
|
@@ -110,8 +115,10 @@ export declare class BaiduMarker extends BaiduOverlay<BMarker> implements Marker
|
|
|
110
115
|
isDraggable(): boolean;
|
|
111
116
|
setZIndex(zIndex?: number): void;
|
|
112
117
|
getZIndex(): number | undefined;
|
|
113
|
-
setLabel(label:
|
|
114
|
-
|
|
118
|
+
setLabel(label: MarkerLabel): void;
|
|
119
|
+
_updateMarkerLabelOffset(): void;
|
|
120
|
+
attachLabelOverlay(label: BaiduLabelOverlay | undefined): void;
|
|
121
|
+
getLabelOverlay(): BaiduLabelOverlay | undefined;
|
|
115
122
|
}
|
|
116
123
|
export declare class GoogleMarker extends GoogleOverlay<google.maps.Marker> implements Marker {
|
|
117
124
|
static create(this: GoogleMap, options: MarkerOptions): GoogleMarker;
|
|
@@ -131,5 +138,6 @@ export declare class GoogleMarker extends GoogleOverlay<google.maps.Marker> impl
|
|
|
131
138
|
isDraggable(): boolean;
|
|
132
139
|
setZIndex(zIndex?: number): void;
|
|
133
140
|
getZIndex(): number | undefined;
|
|
134
|
-
setLabel(label:
|
|
141
|
+
setLabel(label: MarkerLabel): void;
|
|
142
|
+
attachLabelOverlay(label: GoogleLabelOverlay | undefined): void;
|
|
135
143
|
}
|