@baidumap/vue-bmap 1.0.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/LICENSE +21 -0
- package/README.md +271 -0
- package/dist/components/Control/index.d.ts +186 -0
- package/dist/components/Layer/index.d.ts +138 -0
- package/dist/components/Map/Map.d.ts +340 -0
- package/dist/components/Map/MapRef.d.ts +204 -0
- package/dist/components/Map/index.d.ts +4 -0
- package/dist/components/Overlay/InfoWindow.d.ts +193 -0
- package/dist/components/Overlay/index.d.ts +50 -0
- package/dist/components/Overlay/types.d.ts +799 -0
- package/dist/composables/index.d.ts +12 -0
- package/dist/composables/useCapabilities.d.ts +5 -0
- package/dist/composables/useDriver.d.ts +5 -0
- package/dist/composables/useGeocoder.d.ts +17 -0
- package/dist/composables/useIcon.d.ts +5 -0
- package/dist/composables/useMap.d.ts +8 -0
- package/dist/composables/useMapEvent.d.ts +4 -0
- package/dist/composables/useMapReady.d.ts +11 -0
- package/dist/composables/useMapRef.d.ts +8 -0
- package/dist/composables/useServiceTimeout.d.ts +7 -0
- package/dist/composables/useSymbol.d.ts +5 -0
- package/dist/const/index.d.ts +19 -0
- package/dist/constants/index.d.ts +195 -0
- package/dist/context/index.d.ts +31 -0
- package/dist/drivers/capabilityMatrix.d.ts +3 -0
- package/dist/drivers/createDriver.d.ts +18 -0
- package/dist/drivers/types.d.ts +359 -0
- package/dist/drivers/unsupported.d.ts +66 -0
- package/dist/drivers/v3Driver.d.ts +13 -0
- package/dist/drivers/v4Driver.d.ts +15 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +4121 -0
- package/dist/index.js.map +1 -0
- package/dist/loader/index.d.ts +21 -0
- package/dist/loader/registry.d.ts +13 -0
- package/dist/loader/stableHash.d.ts +2 -0
- package/dist/provider/BMapProvider.d.ts +108 -0
- package/dist/types/core.d.ts +82 -0
- package/dist/types/index.d.ts +111 -0
- package/dist/types/results.d.ts +171 -0
- package/dist/types-skd.d.ts +21 -0
- package/dist/utils/createComponent.d.ts +51 -0
- package/dist/utils/debugWarn.d.ts +22 -0
- package/dist/utils/event.d.ts +7 -0
- package/dist/utils/handle.d.ts +16 -0
- package/dist/utils/pointEquals.d.ts +7 -0
- package/dist/utils/sdk.d.ts +47 -0
- package/dist/utils/shallowEqual.d.ts +2 -0
- package/dist/utils/stableStringify.d.ts +10 -0
- package/package.json +71 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BMapVersion, LoadKeyComponents } from '../types';
|
|
2
|
+
|
|
3
|
+
export interface LoaderResult {
|
|
4
|
+
rawSDK: unknown;
|
|
5
|
+
version: BMapVersion;
|
|
6
|
+
loadKey: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 加载 JSAPI 的统一入口。
|
|
10
|
+
*
|
|
11
|
+
* - 通过 @baidumap/jsapi-loader 加载。
|
|
12
|
+
* - 缓存以 loadKey 去重,不重复注入脚本。
|
|
13
|
+
* - 冲突(不同 loadKey)触发 onLoadConflict,返回已加载的 entry。
|
|
14
|
+
* - **不修改 window.BMap / BMapGL 原型、不做命名空间别名**。
|
|
15
|
+
*/
|
|
16
|
+
export declare function loadJSAPI(components: LoadKeyComponents, opts: {
|
|
17
|
+
protocol?: 'http' | 'https';
|
|
18
|
+
timeout?: number;
|
|
19
|
+
globalConfig?: Record<string, unknown>;
|
|
20
|
+
onLoadConflict?: (current: LoadKeyComponents, requested: LoadKeyComponents) => void;
|
|
21
|
+
}): Promise<LoaderResult>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BMapVersion, LoadKeyComponents } from '../types';
|
|
2
|
+
|
|
3
|
+
interface RegistryEntry {
|
|
4
|
+
promise: Promise<unknown>;
|
|
5
|
+
loadKey: string;
|
|
6
|
+
components: LoadKeyComponents;
|
|
7
|
+
}
|
|
8
|
+
export declare function buildLoadKey(c: LoadKeyComponents): string;
|
|
9
|
+
export declare function getExisting(loadKey: string): RegistryEntry | undefined;
|
|
10
|
+
export declare function register(loadKey: string, components: LoadKeyComponents, promise: Promise<unknown>): void;
|
|
11
|
+
export declare function getAllEntries(): RegistryEntry[];
|
|
12
|
+
export declare function detectConflict(loadKey: string, requested: LoadKeyComponents): LoadKeyComponents | null;
|
|
13
|
+
export type { BMapVersion, LoadKeyComponents };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { PropType } from 'vue';
|
|
2
|
+
import { BMapVersion, LoadKeyComponents, UnsupportedBehavior } from '../types';
|
|
3
|
+
|
|
4
|
+
export declare const BMapProvider: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
5
|
+
ak: {
|
|
6
|
+
type: StringConstructor;
|
|
7
|
+
required: true;
|
|
8
|
+
};
|
|
9
|
+
version: {
|
|
10
|
+
type: PropType<BMapVersion>;
|
|
11
|
+
default: string;
|
|
12
|
+
};
|
|
13
|
+
protocol: {
|
|
14
|
+
type: PropType<"http" | "https">;
|
|
15
|
+
default: any;
|
|
16
|
+
};
|
|
17
|
+
serviceHost: {
|
|
18
|
+
type: StringConstructor;
|
|
19
|
+
default: any;
|
|
20
|
+
};
|
|
21
|
+
language: {
|
|
22
|
+
type: StringConstructor;
|
|
23
|
+
default: any;
|
|
24
|
+
};
|
|
25
|
+
plugins: {
|
|
26
|
+
type: PropType<string[]>;
|
|
27
|
+
default: any;
|
|
28
|
+
};
|
|
29
|
+
timeout: {
|
|
30
|
+
type: NumberConstructor;
|
|
31
|
+
default: any;
|
|
32
|
+
};
|
|
33
|
+
globalConfig: {
|
|
34
|
+
type: PropType<Record<string, unknown>>;
|
|
35
|
+
default: any;
|
|
36
|
+
};
|
|
37
|
+
unsupportedBehavior: {
|
|
38
|
+
type: PropType<UnsupportedBehavior>;
|
|
39
|
+
default: string;
|
|
40
|
+
};
|
|
41
|
+
onError: {
|
|
42
|
+
type: PropType<(err: Error) => void>;
|
|
43
|
+
default: any;
|
|
44
|
+
};
|
|
45
|
+
onLoadConflict: {
|
|
46
|
+
type: PropType<(current: LoadKeyComponents, requested: LoadKeyComponents) => void>;
|
|
47
|
+
default: any;
|
|
48
|
+
};
|
|
49
|
+
}>, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
}>[], {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
52
|
+
ak: {
|
|
53
|
+
type: StringConstructor;
|
|
54
|
+
required: true;
|
|
55
|
+
};
|
|
56
|
+
version: {
|
|
57
|
+
type: PropType<BMapVersion>;
|
|
58
|
+
default: string;
|
|
59
|
+
};
|
|
60
|
+
protocol: {
|
|
61
|
+
type: PropType<"http" | "https">;
|
|
62
|
+
default: any;
|
|
63
|
+
};
|
|
64
|
+
serviceHost: {
|
|
65
|
+
type: StringConstructor;
|
|
66
|
+
default: any;
|
|
67
|
+
};
|
|
68
|
+
language: {
|
|
69
|
+
type: StringConstructor;
|
|
70
|
+
default: any;
|
|
71
|
+
};
|
|
72
|
+
plugins: {
|
|
73
|
+
type: PropType<string[]>;
|
|
74
|
+
default: any;
|
|
75
|
+
};
|
|
76
|
+
timeout: {
|
|
77
|
+
type: NumberConstructor;
|
|
78
|
+
default: any;
|
|
79
|
+
};
|
|
80
|
+
globalConfig: {
|
|
81
|
+
type: PropType<Record<string, unknown>>;
|
|
82
|
+
default: any;
|
|
83
|
+
};
|
|
84
|
+
unsupportedBehavior: {
|
|
85
|
+
type: PropType<UnsupportedBehavior>;
|
|
86
|
+
default: string;
|
|
87
|
+
};
|
|
88
|
+
onError: {
|
|
89
|
+
type: PropType<(err: Error) => void>;
|
|
90
|
+
default: any;
|
|
91
|
+
};
|
|
92
|
+
onLoadConflict: {
|
|
93
|
+
type: PropType<(current: LoadKeyComponents, requested: LoadKeyComponents) => void>;
|
|
94
|
+
default: any;
|
|
95
|
+
};
|
|
96
|
+
}>> & Readonly<{}>, {
|
|
97
|
+
version: BMapVersion;
|
|
98
|
+
unsupportedBehavior: UnsupportedBehavior;
|
|
99
|
+
plugins: string[];
|
|
100
|
+
serviceHost: string;
|
|
101
|
+
protocol: "http" | "https";
|
|
102
|
+
timeout: number;
|
|
103
|
+
globalConfig: Record<string, unknown>;
|
|
104
|
+
language: string;
|
|
105
|
+
onError: (err: Error) => void;
|
|
106
|
+
onLoadConflict: (current: LoadKeyComponents, requested: LoadKeyComponents) => void;
|
|
107
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
108
|
+
export type BMapProviderProps = InstanceType<typeof BMapProvider>['$props'];
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Point, Bounds } from '../index';
|
|
2
|
+
|
|
3
|
+
export interface DisplayOptions {
|
|
4
|
+
indoor?: boolean;
|
|
5
|
+
sky?: boolean;
|
|
6
|
+
water?: boolean;
|
|
7
|
+
land?: boolean;
|
|
8
|
+
building?: boolean;
|
|
9
|
+
label?: boolean;
|
|
10
|
+
road?: boolean;
|
|
11
|
+
boundary?: boolean;
|
|
12
|
+
regionText?: boolean;
|
|
13
|
+
street?: boolean;
|
|
14
|
+
poi?: boolean;
|
|
15
|
+
poiText?: boolean;
|
|
16
|
+
poiIcon?: boolean;
|
|
17
|
+
overlayIcon?: boolean;
|
|
18
|
+
overlayText?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface Viewport {
|
|
21
|
+
center: Point;
|
|
22
|
+
zoom: number;
|
|
23
|
+
bounds?: Bounds;
|
|
24
|
+
}
|
|
25
|
+
export interface ViewportOptions {
|
|
26
|
+
margins?: [number, number, number, number];
|
|
27
|
+
zoomFactor?: number;
|
|
28
|
+
icon?: unknown;
|
|
29
|
+
}
|
|
30
|
+
export interface MapStyleConfig {
|
|
31
|
+
features?: Array<{
|
|
32
|
+
featureType: string;
|
|
33
|
+
stylers?: Record<string, unknown>;
|
|
34
|
+
}>;
|
|
35
|
+
style?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface MapStyleV2Options {
|
|
38
|
+
styleJson?: unknown[];
|
|
39
|
+
styleId?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface MapLabel {
|
|
42
|
+
text?: string;
|
|
43
|
+
point?: Point;
|
|
44
|
+
fontColor?: string;
|
|
45
|
+
fontSize?: number;
|
|
46
|
+
bgColor?: string;
|
|
47
|
+
bdColor?: string;
|
|
48
|
+
bdWidth?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface MapPanes {
|
|
51
|
+
floatPane?: HTMLElement;
|
|
52
|
+
markerMouseTarget?: HTMLElement;
|
|
53
|
+
markerPane?: HTMLElement;
|
|
54
|
+
markerShadow?: HTMLElement;
|
|
55
|
+
mapPane?: HTMLElement;
|
|
56
|
+
}
|
|
57
|
+
export interface ViewAnimationOptions {
|
|
58
|
+
duration?: number;
|
|
59
|
+
transition?: number;
|
|
60
|
+
delay?: number;
|
|
61
|
+
iterationCount?: number;
|
|
62
|
+
direction?: string;
|
|
63
|
+
easing?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface ViewAnimationKeyFrames {
|
|
66
|
+
center?: Point;
|
|
67
|
+
zoom?: number;
|
|
68
|
+
heading?: number;
|
|
69
|
+
tilt?: number;
|
|
70
|
+
}
|
|
71
|
+
export interface ViewAnimation {
|
|
72
|
+
keyFrames?: Array<ViewAnimationKeyFrames>;
|
|
73
|
+
options?: ViewAnimationOptions;
|
|
74
|
+
}
|
|
75
|
+
export interface Projection {
|
|
76
|
+
lngLatToPoint?(point: Point): Point;
|
|
77
|
+
pointToLngLat?(point: Point): Point;
|
|
78
|
+
}
|
|
79
|
+
export interface PredictDate {
|
|
80
|
+
weekday: number;
|
|
81
|
+
hour: number;
|
|
82
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 核心类型定义。
|
|
3
|
+
*
|
|
4
|
+
* 类型来源:bmap-jsapi-dts(src 目录下的 .d.ts 文件)。
|
|
5
|
+
* 本文件只重新组织「库内部需要」的类型形态,不重复 dts 的完整 API 描述。
|
|
6
|
+
* 具体 SDK 类(Map/Marker/...)的成员在 dts 中查阅,库内部用 brand handle 包装。
|
|
7
|
+
*/
|
|
8
|
+
export interface Point {
|
|
9
|
+
lng: number;
|
|
10
|
+
lat: number;
|
|
11
|
+
}
|
|
12
|
+
export interface Pixel {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
}
|
|
16
|
+
export interface Size {
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
}
|
|
20
|
+
export interface Bounds {
|
|
21
|
+
sw: Point;
|
|
22
|
+
ne: Point;
|
|
23
|
+
}
|
|
24
|
+
export interface MapHandle {
|
|
25
|
+
readonly __brand: 'MapHandle';
|
|
26
|
+
readonly raw: unknown;
|
|
27
|
+
}
|
|
28
|
+
export interface OverlayHandle {
|
|
29
|
+
readonly __brand: 'OverlayHandle';
|
|
30
|
+
readonly raw: unknown;
|
|
31
|
+
readonly type: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ControlHandle {
|
|
34
|
+
readonly __brand: 'ControlHandle';
|
|
35
|
+
readonly raw: unknown;
|
|
36
|
+
readonly type: string;
|
|
37
|
+
}
|
|
38
|
+
export interface LayerHandle {
|
|
39
|
+
readonly __brand: 'LayerHandle';
|
|
40
|
+
readonly raw: unknown;
|
|
41
|
+
readonly kind: LayerKind;
|
|
42
|
+
}
|
|
43
|
+
export interface ServiceHandle {
|
|
44
|
+
readonly __brand: 'ServiceHandle';
|
|
45
|
+
readonly raw: unknown;
|
|
46
|
+
readonly isNull: boolean;
|
|
47
|
+
}
|
|
48
|
+
export type LayerKind = 'tile' | 'normal' | 'geojson' | 'district' | 'traffic' | 'custom' | 'canvas';
|
|
49
|
+
/**
|
|
50
|
+
* JSAPI 版本。
|
|
51
|
+
*
|
|
52
|
+
* 框架显式支持 '3.0' 与 '4.0',但允许传入任意字符串(如未来的 '4.1'、'5.0')。
|
|
53
|
+
* - '3.0':使用 v3Driver
|
|
54
|
+
* - 其它任何值('4.0' / '4.1' / '5.0' / ...):使用 v4Driver,按 4.0 baseline 处理
|
|
55
|
+
* - jsapi-loader 始终按用户传入的 version 加载
|
|
56
|
+
*
|
|
57
|
+
* `(string & {})` 是 TS 的常见技巧:既允许任意字符串,又能在 IDE 里给出 '3.0' / '4.0' 的补全提示。
|
|
58
|
+
*/
|
|
59
|
+
export type BMapVersion = '3.0' | '4.0' | (string & {});
|
|
60
|
+
export type UnsupportedBehavior = 'throw' | 'warn' | 'ignore';
|
|
61
|
+
/**
|
|
62
|
+
* 能力标识。
|
|
63
|
+
*
|
|
64
|
+
* 完整清单由 scripts/gen-capability-matrix.ts 从 bmap-jsapi-dts 的
|
|
65
|
+
* @since / @removed 自动生成。此处仅手写常见项作为种子。
|
|
66
|
+
* 真正的能力矩阵见 src/drivers/capabilityMatrix.ts。
|
|
67
|
+
*/
|
|
68
|
+
export type Capability = string;
|
|
69
|
+
export interface BMapEvent<T = unknown> {
|
|
70
|
+
type: string;
|
|
71
|
+
target: MapHandle | OverlayHandle | ControlHandle | null;
|
|
72
|
+
point?: Point;
|
|
73
|
+
pixel?: Pixel;
|
|
74
|
+
overlay?: OverlayHandle;
|
|
75
|
+
raw: T;
|
|
76
|
+
}
|
|
77
|
+
/** Map 鼠标/触摸事件(click, dblclick, rightclick, mousemove, mousedown, mouseup, mouseover, mouseout, touchstart, touchmove, touchend, longpress) */
|
|
78
|
+
export interface MapMouseEvent {
|
|
79
|
+
type: string;
|
|
80
|
+
target: MapHandle;
|
|
81
|
+
point: Point;
|
|
82
|
+
pixel: Pixel;
|
|
83
|
+
overlay?: OverlayHandle;
|
|
84
|
+
}
|
|
85
|
+
/** Map 移动/拖拽事件(dragstart, dragging, dragend, movestart, moving, moveend) */
|
|
86
|
+
export interface MapMoveEvent {
|
|
87
|
+
type: string;
|
|
88
|
+
target: MapHandle;
|
|
89
|
+
point: Point;
|
|
90
|
+
center?: Point;
|
|
91
|
+
}
|
|
92
|
+
/** Map 缩放事件(zoomstart, zooming, zoomend) */
|
|
93
|
+
export interface MapZoomEvent {
|
|
94
|
+
type: string;
|
|
95
|
+
target: MapHandle;
|
|
96
|
+
zoom?: number;
|
|
97
|
+
}
|
|
98
|
+
/** Map 通用事件(resize, tilesloaded, maptypechange) */
|
|
99
|
+
export interface MapEvent {
|
|
100
|
+
type: string;
|
|
101
|
+
target: MapHandle;
|
|
102
|
+
[key: string]: unknown;
|
|
103
|
+
}
|
|
104
|
+
export type LoaderStatus = 'loading' | 'ready' | 'error';
|
|
105
|
+
export interface LoadKeyComponents {
|
|
106
|
+
version: BMapVersion;
|
|
107
|
+
ak: string;
|
|
108
|
+
serviceHost?: string;
|
|
109
|
+
language?: string;
|
|
110
|
+
plugins?: string[];
|
|
111
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { Point } from '../types';
|
|
2
|
+
|
|
3
|
+
export interface LocalResultPoi {
|
|
4
|
+
title: string;
|
|
5
|
+
point: Point;
|
|
6
|
+
address: string;
|
|
7
|
+
phoneNumber: string;
|
|
8
|
+
tags?: string[];
|
|
9
|
+
url?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface LocalResult {
|
|
12
|
+
keyword: string;
|
|
13
|
+
getCurrentNumPois(): number;
|
|
14
|
+
getPoi(i: number): LocalResultPoi;
|
|
15
|
+
getNumPois(): number;
|
|
16
|
+
getNumPages(): number;
|
|
17
|
+
getCurrentPage(): number;
|
|
18
|
+
city: string;
|
|
19
|
+
}
|
|
20
|
+
export interface AddressComponent {
|
|
21
|
+
province: string;
|
|
22
|
+
city: string;
|
|
23
|
+
district: string;
|
|
24
|
+
street: string;
|
|
25
|
+
streetNumber: string;
|
|
26
|
+
}
|
|
27
|
+
export interface GeocoderResult {
|
|
28
|
+
point: Point;
|
|
29
|
+
address: string;
|
|
30
|
+
addressComponents: AddressComponent;
|
|
31
|
+
surroundingPoi?: LocalResultPoi[];
|
|
32
|
+
business: string;
|
|
33
|
+
}
|
|
34
|
+
export interface Step {
|
|
35
|
+
point: Point;
|
|
36
|
+
distance: number;
|
|
37
|
+
duration: number;
|
|
38
|
+
instructions: string;
|
|
39
|
+
}
|
|
40
|
+
export interface Route {
|
|
41
|
+
getDistance(includeTraffic?: boolean): {
|
|
42
|
+
value: number;
|
|
43
|
+
};
|
|
44
|
+
getNumSteps(): number;
|
|
45
|
+
getStep(i: number): Step;
|
|
46
|
+
getPath(): Point[];
|
|
47
|
+
}
|
|
48
|
+
export interface RoutePlan {
|
|
49
|
+
getNumRoutes(): number;
|
|
50
|
+
getRoute(i: number): Route;
|
|
51
|
+
getDistance(includeTraffic?: boolean): {
|
|
52
|
+
value: number;
|
|
53
|
+
};
|
|
54
|
+
getDuration(includeTraffic?: boolean): {
|
|
55
|
+
value: number;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface DrivingRouteResult {
|
|
59
|
+
policy?: number;
|
|
60
|
+
taxiFare?: TaxiFare;
|
|
61
|
+
getNumPlans(): number;
|
|
62
|
+
getPlan(i: number): RoutePlan;
|
|
63
|
+
}
|
|
64
|
+
export type WalkingRouteResult = DrivingRouteResult;
|
|
65
|
+
export type RidingRouteResult = DrivingRouteResult;
|
|
66
|
+
export interface TransitLine {
|
|
67
|
+
title: string;
|
|
68
|
+
getNumStops?(): number;
|
|
69
|
+
}
|
|
70
|
+
export interface TransitPlan {
|
|
71
|
+
getNumLines(): number;
|
|
72
|
+
getLine(i: number): TransitLine;
|
|
73
|
+
getDistance(includeTraffic?: boolean): {
|
|
74
|
+
value: number;
|
|
75
|
+
};
|
|
76
|
+
getDuration(includeTraffic?: boolean): {
|
|
77
|
+
value: number;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export interface TransitRouteResult {
|
|
81
|
+
policy?: number;
|
|
82
|
+
getNumPlans(): number;
|
|
83
|
+
getPlan(i: number): TransitPlan;
|
|
84
|
+
}
|
|
85
|
+
export interface BusStation {
|
|
86
|
+
name: string;
|
|
87
|
+
point: Point;
|
|
88
|
+
}
|
|
89
|
+
export interface BusLine {
|
|
90
|
+
name: string;
|
|
91
|
+
uid?: string;
|
|
92
|
+
getNumStations?(): number;
|
|
93
|
+
}
|
|
94
|
+
export interface BusListItem {
|
|
95
|
+
uid?: string;
|
|
96
|
+
name: string;
|
|
97
|
+
}
|
|
98
|
+
export interface BusListResult {
|
|
99
|
+
getNumBusList(): number;
|
|
100
|
+
getBusListItem(i: number): BusListItem;
|
|
101
|
+
}
|
|
102
|
+
export interface AutocompleteResultPoi {
|
|
103
|
+
business?: string;
|
|
104
|
+
city?: string;
|
|
105
|
+
district?: string;
|
|
106
|
+
uid?: string;
|
|
107
|
+
address?: string;
|
|
108
|
+
point?: Point;
|
|
109
|
+
}
|
|
110
|
+
export interface AutocompleteResult {
|
|
111
|
+
getList?(): AutocompleteResultPoi[];
|
|
112
|
+
}
|
|
113
|
+
export interface GeolocationResult {
|
|
114
|
+
point: Point;
|
|
115
|
+
accuracy?: number;
|
|
116
|
+
address?: string;
|
|
117
|
+
}
|
|
118
|
+
export interface LocalCityResult {
|
|
119
|
+
center: Point;
|
|
120
|
+
level: number;
|
|
121
|
+
name: string;
|
|
122
|
+
code?: number;
|
|
123
|
+
}
|
|
124
|
+
export interface TranslateResults {
|
|
125
|
+
status?: number;
|
|
126
|
+
points?: Point[];
|
|
127
|
+
size?(): number;
|
|
128
|
+
}
|
|
129
|
+
export interface TaxiFareDetail {
|
|
130
|
+
day?: {
|
|
131
|
+
totalPrice?: number;
|
|
132
|
+
distance?: number;
|
|
133
|
+
duration?: number;
|
|
134
|
+
detail?: unknown;
|
|
135
|
+
};
|
|
136
|
+
night?: {
|
|
137
|
+
totalPrice?: number;
|
|
138
|
+
distance?: number;
|
|
139
|
+
duration?: number;
|
|
140
|
+
detail?: unknown;
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export interface TaxiFare {
|
|
144
|
+
distance: number;
|
|
145
|
+
duration: number;
|
|
146
|
+
detail: TaxiFareDetail;
|
|
147
|
+
}
|
|
148
|
+
export interface PanoramaData {
|
|
149
|
+
id?: string;
|
|
150
|
+
links?: unknown[];
|
|
151
|
+
pov?: {
|
|
152
|
+
heading?: number;
|
|
153
|
+
pitch?: number;
|
|
154
|
+
zoom?: number;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
export interface BoundaryResult {
|
|
158
|
+
boundaries: string[];
|
|
159
|
+
}
|
|
160
|
+
export interface RenderOptions {
|
|
161
|
+
map?: unknown;
|
|
162
|
+
panel?: string | HTMLElement;
|
|
163
|
+
selectFirstResult?: boolean;
|
|
164
|
+
autoViewport?: boolean;
|
|
165
|
+
highlightMode?: number;
|
|
166
|
+
viewportOptions?: ViewportOptions;
|
|
167
|
+
}
|
|
168
|
+
export interface ViewportOptions {
|
|
169
|
+
margins?: number[];
|
|
170
|
+
zoomFactor?: number;
|
|
171
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK 类型的占位(开发时按 bmap-jsapi-dts 全量替换)。
|
|
3
|
+
*
|
|
4
|
+
* 当前为框架占位类型,避免组件实现阻塞。
|
|
5
|
+
*/
|
|
6
|
+
export interface Icon {
|
|
7
|
+
__iconBrand?: 'BMap.Icon';
|
|
8
|
+
url?: string;
|
|
9
|
+
size?: import('.').Size;
|
|
10
|
+
[k: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
export type Size = {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
};
|
|
16
|
+
export type ControlAnchor = number;
|
|
17
|
+
export interface Label {
|
|
18
|
+
__labelBrand?: 'BMap.Label';
|
|
19
|
+
content?: string;
|
|
20
|
+
[k: string]: unknown;
|
|
21
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { OverlayTargetType } from '../context';
|
|
2
|
+
import { BMapDriver } from '../drivers/types';
|
|
3
|
+
import { ControlHandle, LayerHandle, OverlayHandle } from '../types';
|
|
4
|
+
|
|
5
|
+
export interface OverlayComponentConfig<P> {
|
|
6
|
+
factory: (driver: BMapDriver, props: P) => OverlayHandle | null;
|
|
7
|
+
positionProp?: keyof P & string;
|
|
8
|
+
pathProp?: keyof P & string;
|
|
9
|
+
optionProps?: Array<keyof P & string>;
|
|
10
|
+
ctorOnlyProps?: Array<keyof P & string>;
|
|
11
|
+
supportsChildren?: boolean;
|
|
12
|
+
childTargetType?: OverlayTargetType;
|
|
13
|
+
attachToMarkerAsLabel?: boolean;
|
|
14
|
+
events?: Array<{
|
|
15
|
+
sdk: string;
|
|
16
|
+
prop: keyof P & string;
|
|
17
|
+
}>;
|
|
18
|
+
displayName?: string;
|
|
19
|
+
skipMount?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface ControlComponentConfig<P> {
|
|
22
|
+
factory: (driver: BMapDriver, props: P) => ControlHandle | null;
|
|
23
|
+
optionProps?: Array<keyof P & string>;
|
|
24
|
+
ctorOnlyProps?: Array<keyof P & string>;
|
|
25
|
+
events?: Array<{
|
|
26
|
+
sdk: string;
|
|
27
|
+
prop: keyof P & string;
|
|
28
|
+
}>;
|
|
29
|
+
displayName?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface LayerComponentConfig<P> {
|
|
32
|
+
factory: (driver: BMapDriver, props: P) => LayerHandle | null;
|
|
33
|
+
addMethod?: keyof BMapDriver;
|
|
34
|
+
removeMethod?: keyof BMapDriver;
|
|
35
|
+
events?: ReadonlyArray<{
|
|
36
|
+
sdk: string;
|
|
37
|
+
prop: keyof P & string;
|
|
38
|
+
}>;
|
|
39
|
+
displayName?: string;
|
|
40
|
+
}
|
|
41
|
+
export declare function createOverlayComponent<P extends Record<string, any>>(config: OverlayComponentConfig<P>): import('vue').DefineComponent<{}, () => any, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {} | {
|
|
42
|
+
[x: string]: any;
|
|
43
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
44
|
+
export declare function createControlComponent<P extends Record<string, any>>(config: ControlComponentConfig<P>): import('vue').DefineComponent<{}, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
45
|
+
[key: string]: any;
|
|
46
|
+
}>[], {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {} | {
|
|
47
|
+
[x: string]: any;
|
|
48
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
49
|
+
export declare function createLayerComponent<P extends Record<string, any>>(config: LayerComponentConfig<P>): import('vue').DefineComponent<{}, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
}>[], {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 开发期非抛出型告警。
|
|
3
|
+
*
|
|
4
|
+
* 用途:包住那些「用户明确要求某个操作、但 SDK 静默失败」的 catch —— 例如
|
|
5
|
+
* Layer.setData 没渲染、Map 的属性 setter 没生效。这些位置以前是 `catch { /* noop *\/ }`,
|
|
6
|
+
* 故障被完全吞掉,开发时无从排查。
|
|
7
|
+
*
|
|
8
|
+
* 设计约束:
|
|
9
|
+
* - 只在非 production 打印(对齐 v4Driver 里的 env 判断),避免污染线上 console。
|
|
10
|
+
* - 绝不抛异常:这些 catch 多在 React effect 回调里,抛出会破坏渲染树。日志本身也 try 兜底。
|
|
11
|
+
* - 不走 reportUnsupported:那是「能力不支持」语义、且 throw 模式会抛错;这里是
|
|
12
|
+
* 受支持操作的运行时失败,只需可观测,不改变控制流。
|
|
13
|
+
*/
|
|
14
|
+
export declare function debugWarn(context: string, cause?: unknown): void;
|
|
15
|
+
/**
|
|
16
|
+
* 开发期提示(原文输出,不追加「调用失败」)。
|
|
17
|
+
*
|
|
18
|
+
* 用途:不是调用失败、但用户几乎一定会误解的场景 —— 例如把某个 option prop 改回
|
|
19
|
+
* undefined,框架没有 SDK 默认值可以还原,只能保持原状。这类「符合实现、但违背直觉」
|
|
20
|
+
* 的行为不说出来就是静默失效。
|
|
21
|
+
*/
|
|
22
|
+
export declare function devWarn(message: string, cause?: unknown): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brand handle 工具。
|
|
3
|
+
*
|
|
4
|
+
* 框架对外暴露的 Map/Overlay/... 都是 brand handle(`{ __brand, raw }`),
|
|
5
|
+
* 传给 SDK 前需要解包出内部的 raw 实例。集中在此处理,
|
|
6
|
+
* 避免在各 hook / 组件里散落 `(x as any).__brand` / `(x as any).raw`。
|
|
7
|
+
*/
|
|
8
|
+
interface BrandHandle {
|
|
9
|
+
readonly __brand: string;
|
|
10
|
+
readonly raw: unknown;
|
|
11
|
+
}
|
|
12
|
+
/** 判断值是否为 brand handle。 */
|
|
13
|
+
export declare function isHandle(value: unknown): value is BrandHandle;
|
|
14
|
+
/** 若是 brand handle 则解包出内部 raw SDK 实例,否则原样返回。 */
|
|
15
|
+
export declare function unwrapHandle(value: unknown): unknown;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 全局 BMap SDK 访问入口。
|
|
3
|
+
*
|
|
4
|
+
* SDK 脚本由 jsapi-loader 注入到全局(v3 为 `BMap`,v4 的 `BMapGL` 出于兼容
|
|
5
|
+
* 也会挂 `BMap` 别名)。这里集中收敛对全局对象的类型断言,
|
|
6
|
+
* 避免在各 hook / 组件里散落 `(globalThis as any).BMap`。
|
|
7
|
+
*
|
|
8
|
+
* 构造器签名直接取自官方类型包 `@baidumap/jsapi-v4-types` 的全局 `BMap` 命名空间,
|
|
9
|
+
* 所以 `new SDK.Point(...)` 得到的是真正的 `BMap.Point`,而不是 `unknown`。
|
|
10
|
+
*/
|
|
11
|
+
/// <reference types="@baidumap/jsapi-v4-types" />
|
|
12
|
+
/**
|
|
13
|
+
* 官方类型包尚未声明、但本库运行时确实会用到的构造器。
|
|
14
|
+
*
|
|
15
|
+
* 这里只补「官方缺、我们用」的部分 —— 官方补齐后应当从此处删掉,
|
|
16
|
+
* 而不是让手写声明和官方声明长期并存。
|
|
17
|
+
*/
|
|
18
|
+
interface BMapSDKExtras {
|
|
19
|
+
/** v4 的地图遮罩层,官方类型包未声明;见 components/Overlay/MapMask.tsx */
|
|
20
|
+
readonly MapMask: new (points: BMap.Point[], opts?: Record<string, unknown>) => unknown;
|
|
21
|
+
/** v4 的简易信息窗,官方类型包未声明;见 components/Overlay/SimpleInfoWindow.tsx */
|
|
22
|
+
readonly SimpleInfoWindow: new (content: string | HTMLElement, opts?: Record<string, unknown>) => unknown;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 运行时全局 SDK 对象的类型。
|
|
26
|
+
*
|
|
27
|
+
* - `typeof BMap`:官方命名空间里的全部构造器与常量,带完整参数/返回值签名
|
|
28
|
+
* - `BMapSDKExtras`:补齐官方尚未声明的成员
|
|
29
|
+
* - 索引签名:v3/v4 之间成员存在差异,未知成员以 `unknown` 兜底,由调用方自行断言
|
|
30
|
+
*
|
|
31
|
+
* 交集类型下,已声明的成员优先于索引签名解析,因此 `SDK.Point` 仍是精确类型。
|
|
32
|
+
*/
|
|
33
|
+
export type BMapSDK = typeof BMap & BMapSDKExtras & {
|
|
34
|
+
readonly [key: string]: unknown;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* 获取全局 BMap SDK 对象;若脚本尚未注入则抛出清晰错误。
|
|
38
|
+
* 适用于随后直接访问 `SDK.Point` 等构造器的调用方 —— 相比原先返回
|
|
39
|
+
* undefined 后触发的 `Cannot read properties of undefined`,这里给出可读的失败原因。
|
|
40
|
+
*/
|
|
41
|
+
export declare function getSDK(): BMapSDK;
|
|
42
|
+
/**
|
|
43
|
+
* 获取全局 BMap SDK 对象;未注入时返回 undefined。
|
|
44
|
+
* 供可优雅降级的调用方使用(如运行时常量回退、组件在 SDK 缺失时静默跳过)。
|
|
45
|
+
*/
|
|
46
|
+
export declare function tryGetSDK(): BMapSDK | undefined;
|
|
47
|
+
export {};
|