@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,359 @@
|
|
|
1
|
+
import { BMapVersion, Capability, LayerKind, LoadKeyComponents, UnsupportedBehavior, Bounds, ControlHandle, LayerHandle, MapHandle, OverlayHandle, Pixel, Point, ServiceHandle, Size } from '../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* BMapDriver 接口 — 完整覆盖 bmap-jsapi-dts 中 Map 类的全部公共方法。
|
|
5
|
+
*
|
|
6
|
+
* 分类(按 dts src/core/Map.d.ts 顺序):
|
|
7
|
+
* 1. Map 工厂 / 销毁
|
|
8
|
+
* 2. 交互开关(enable/disable 系列)
|
|
9
|
+
* 3. 视角控制(heading / tilt / rotate)
|
|
10
|
+
* 4. 缩放级别(zoom / minZoom / maxZoom)
|
|
11
|
+
* 5. 自动 resize
|
|
12
|
+
* 6. 显示配置(displayOptions / setOptions)
|
|
13
|
+
* 7. 容器信息(size / container)
|
|
14
|
+
* 8. 坐标转换(point/pixel/mercator)
|
|
15
|
+
* 9. 地图状态查询
|
|
16
|
+
* 10. 地图标注 / Spots / 区域
|
|
17
|
+
* 11. 视野控制(center / zoom / pan / flyTo / viewport)
|
|
18
|
+
* 12. 地图类型
|
|
19
|
+
* 13. 控件 / 右键菜单
|
|
20
|
+
* 14. 覆盖物
|
|
21
|
+
* 15. 图层(addLayer / addNormalLayer / addGeoJSONLayer / addDistrictLayer / traffic / tileLayer)
|
|
22
|
+
* 16. 信息窗口
|
|
23
|
+
* 17. 样式 / 主题
|
|
24
|
+
* 18. 视角动画
|
|
25
|
+
* 19. 截图 / 版权
|
|
26
|
+
* 20. 地球模式 / 室内 / 街景 / 语言 / 私有 / 焦点遮罩 / 自定义 HTML 图层 / 停车场等
|
|
27
|
+
* 21. 3.0-only(setPanorama / addHotspot / setCurrentCity / highResolution 等)
|
|
28
|
+
* 22. Overlay/Control/Layer/Service/ContextMenu/Panorama 工厂与操作
|
|
29
|
+
* 23. 事件
|
|
30
|
+
*
|
|
31
|
+
* 关键约定(DESIGN.md §12):
|
|
32
|
+
* - 工厂方法:不支持时返回 null 或 isNull: true 的 ServiceHandle。
|
|
33
|
+
* - 命令方法:签名 void,不支持时按 unsupportedBehavior(throw / warn+noop / ignore+noop)。
|
|
34
|
+
* - Getter:签名与 dts 一致;不支持时按 behavior:throw / warn+NaN或合理兜底 / ignore。
|
|
35
|
+
* - **绝不污染原返回类型为 T | undefined**。
|
|
36
|
+
*/
|
|
37
|
+
export interface BMapDriver {
|
|
38
|
+
readonly version: BMapVersion;
|
|
39
|
+
readonly rawSDK: unknown;
|
|
40
|
+
readonly capabilities: ReadonlySet<Capability>;
|
|
41
|
+
readonly unsupportedBehavior: UnsupportedBehavior;
|
|
42
|
+
createMap(container: HTMLElement, options: unknown): MapHandle;
|
|
43
|
+
destroyMap(handle: MapHandle): void;
|
|
44
|
+
enableDragging(map: MapHandle): void;
|
|
45
|
+
disableDragging(map: MapHandle): void;
|
|
46
|
+
enableInertialDragging(map: MapHandle): void;
|
|
47
|
+
disableInertialDragging(map: MapHandle): void;
|
|
48
|
+
enableScrollWheelZoom(map: MapHandle): void;
|
|
49
|
+
disableScrollWheelZoom(map: MapHandle): void;
|
|
50
|
+
enableContinuousZoom(map: MapHandle): void;
|
|
51
|
+
disableContinuousZoom(map: MapHandle): void;
|
|
52
|
+
enableResizeOnCenter(map: MapHandle): void;
|
|
53
|
+
disableResizeOnCenter(map: MapHandle): void;
|
|
54
|
+
enableDoubleClickZoom(map: MapHandle): void;
|
|
55
|
+
disableDoubleClickZoom(map: MapHandle): void;
|
|
56
|
+
enableKeyboard(map: MapHandle): void;
|
|
57
|
+
disableKeyboard(map: MapHandle): void;
|
|
58
|
+
enablePinchToZoom(map: MapHandle): void;
|
|
59
|
+
disablePinchToZoom(map: MapHandle): void;
|
|
60
|
+
enableRotate(map: MapHandle): void;
|
|
61
|
+
disableRotate(map: MapHandle): void;
|
|
62
|
+
enableRotateGestures(map: MapHandle): void;
|
|
63
|
+
disableRotateGestures(map: MapHandle): void;
|
|
64
|
+
enableTilt(map: MapHandle): void;
|
|
65
|
+
disableTilt(map: MapHandle): void;
|
|
66
|
+
enableTiltGestures(map: MapHandle): void;
|
|
67
|
+
disableTiltGestures(map: MapHandle): void;
|
|
68
|
+
enableAutoResize(map: MapHandle): void;
|
|
69
|
+
disableAutoResize(map: MapHandle): void;
|
|
70
|
+
/** 开启点击底图标注后自动展示信息窗口,同时会开启底图标注点击(4.0+) */
|
|
71
|
+
enableIconInfoWindow(map: MapHandle): void;
|
|
72
|
+
disableIconInfoWindow(map: MapHandle): void;
|
|
73
|
+
/** 启用首选语言,language 使用 BMAP_LANGUAGE_* 常量(4.0+) */
|
|
74
|
+
enablePreferredLanguage(map: MapHandle, language?: string): void;
|
|
75
|
+
disablePreferredLanguage(map: MapHandle): void;
|
|
76
|
+
setHeading(map: MapHandle, heading: number, options?: unknown): void;
|
|
77
|
+
getHeading(map: MapHandle): number;
|
|
78
|
+
setTilt(map: MapHandle, tilt: number, options?: unknown): void;
|
|
79
|
+
getTilt(map: MapHandle): number;
|
|
80
|
+
getCurrentMaxTilt(map: MapHandle): number;
|
|
81
|
+
setMinZoom(map: MapHandle, zoom: number): void;
|
|
82
|
+
setMaxZoom(map: MapHandle, zoom: number): void;
|
|
83
|
+
getMinZoom(map: MapHandle): number;
|
|
84
|
+
getMaxZoom(map: MapHandle): number;
|
|
85
|
+
checkResize(map: MapHandle): void;
|
|
86
|
+
resize(map: MapHandle): void;
|
|
87
|
+
setSize(map: MapHandle, size: {
|
|
88
|
+
width: number;
|
|
89
|
+
height: number;
|
|
90
|
+
}): void;
|
|
91
|
+
zoomTo(map: MapHandle, level: number, point?: unknown): void;
|
|
92
|
+
setDisplayOptions(map: MapHandle, options: unknown): void;
|
|
93
|
+
setOptions(map: MapHandle, options: unknown): void;
|
|
94
|
+
getSize(map: MapHandle): Size;
|
|
95
|
+
getContainerSize(map: MapHandle): Size;
|
|
96
|
+
getZoomUnits(map: MapHandle): number;
|
|
97
|
+
getContainer(map: MapHandle): HTMLElement;
|
|
98
|
+
pixelToPoint(map: MapHandle, pixel: Pixel, options?: unknown): Point;
|
|
99
|
+
pointToPixel(map: MapHandle, point: Point, options?: unknown): Pixel;
|
|
100
|
+
lnglatToMercator(map: MapHandle, lng: number, lat: number): [number, number];
|
|
101
|
+
mercatorToLnglat(map: MapHandle, mcLng: number, mcLat: number): [number, number];
|
|
102
|
+
pointToOverlayPixel(map: MapHandle, point: Point, options?: unknown): Pixel;
|
|
103
|
+
overlayPixelToPoint(map: MapHandle, pixel: Pixel, options?: unknown): Point;
|
|
104
|
+
getDistance(map: MapHandle, start: Point, end: Point): number;
|
|
105
|
+
isLoaded(map: MapHandle): boolean;
|
|
106
|
+
getCoordType(map: MapHandle): string;
|
|
107
|
+
getMapTypeId(map: MapHandle): string;
|
|
108
|
+
getMapCoordType(map: MapHandle): string;
|
|
109
|
+
getMapStyleId(map: MapHandle): string;
|
|
110
|
+
getAreaStyleId(map: MapHandle): string;
|
|
111
|
+
getRenderType(map: MapHandle): string;
|
|
112
|
+
isCanvasMap(map: MapHandle): boolean;
|
|
113
|
+
getProjection(map: MapHandle): unknown;
|
|
114
|
+
getSolarInfo(map: MapHandle, date: Date): unknown;
|
|
115
|
+
getTileId(map: MapHandle, point: Point, level: number): string;
|
|
116
|
+
getPoiByUid(map: MapHandle, uid: string, callback: (poi: unknown) => void): void;
|
|
117
|
+
getPanes(map: MapHandle): unknown;
|
|
118
|
+
getInfoWindow(map: MapHandle): OverlayHandle | null;
|
|
119
|
+
addSpots(map: MapHandle, spots: unknown[], options?: unknown): string;
|
|
120
|
+
getSpots(map: MapHandle, id: string): unknown[];
|
|
121
|
+
removeSpots(map: MapHandle, id: string): void;
|
|
122
|
+
clearSpots(map: MapHandle): void;
|
|
123
|
+
resetSpotStatus(map: MapHandle): void;
|
|
124
|
+
hightlightSpotByUid(map: MapHandle, uid: string, tilePosStr: string): void;
|
|
125
|
+
addAreaSpot(map: MapHandle, areaSpot: number[], options?: unknown): string;
|
|
126
|
+
getAreaSpot(map: MapHandle, id: string): number[];
|
|
127
|
+
removeAreaSpot(map: MapHandle, id: string): void;
|
|
128
|
+
clearAreaSpots(map: MapHandle): void;
|
|
129
|
+
clearLabels(map: MapHandle): void;
|
|
130
|
+
addMapLabels(map: MapHandle, labels: unknown[]): string[];
|
|
131
|
+
removeMapLabels(map: MapHandle, labelUids: string[]): void;
|
|
132
|
+
getIconByClickPosition(map: MapHandle, clickPosition: Pixel): unknown | null;
|
|
133
|
+
setBounds(map: MapHandle, bounds: Bounds): void;
|
|
134
|
+
centerAndZoom(map: MapHandle, center: Point | string, zoom?: number, options?: unknown): void;
|
|
135
|
+
panTo(map: MapHandle, center: Point, options?: unknown): void;
|
|
136
|
+
panBy(map: MapHandle, x: number, y: number, options?: unknown): void;
|
|
137
|
+
flyTo(map: MapHandle, center: Point, zoom: number, options?: unknown): void;
|
|
138
|
+
reset(map: MapHandle): void;
|
|
139
|
+
setCenter(map: MapHandle, center: Point | string, options?: unknown): void;
|
|
140
|
+
getCenter(map: MapHandle): Point;
|
|
141
|
+
setViewport(map: MapHandle, view: Point[] | Bounds, viewportOptions?: unknown): void;
|
|
142
|
+
getViewport(map: MapHandle, view: Point[] | Bounds, viewportOptions?: unknown): unknown;
|
|
143
|
+
setZoom(map: MapHandle, zoom: number, options?: unknown): void;
|
|
144
|
+
getZoom(map: MapHandle): number;
|
|
145
|
+
zoomIn(map: MapHandle, zoomCenter?: Point): void;
|
|
146
|
+
zoomOut(map: MapHandle, zoomCenter?: Point): void;
|
|
147
|
+
getBounds(map: MapHandle): Bounds;
|
|
148
|
+
restrictBounds(map: MapHandle, bounds: Bounds | null): void;
|
|
149
|
+
setMapType(map: MapHandle, mapTypeId: string | number): void;
|
|
150
|
+
getMapType(map: MapHandle): string;
|
|
151
|
+
addControl(map: MapHandle, control: ControlHandle): void;
|
|
152
|
+
removeControl(map: MapHandle, control: ControlHandle): void;
|
|
153
|
+
setControlOptions(control: ControlHandle, options: unknown): void;
|
|
154
|
+
showControl(control: ControlHandle): void;
|
|
155
|
+
hideControl(control: ControlHandle): void;
|
|
156
|
+
addContextMenu(map: MapHandle | OverlayHandle, menu: OverlayHandle): void;
|
|
157
|
+
removeContextMenu(map: MapHandle | OverlayHandle, menu: OverlayHandle): void;
|
|
158
|
+
addOverlay(map: MapHandle, overlay: OverlayHandle): void;
|
|
159
|
+
removeOverlay(map: MapHandle, overlay: OverlayHandle): void;
|
|
160
|
+
clearOverlays(map: MapHandle): void;
|
|
161
|
+
getOverlays(map: MapHandle): OverlayHandle[];
|
|
162
|
+
/** 把 Label 挂到 Marker 上(marker.setLabel),随 marker 定位/拖拽跟随(4.0/GL 与 3.0 均支持) */
|
|
163
|
+
setMarkerLabel(marker: OverlayHandle, label: OverlayHandle): void;
|
|
164
|
+
/** 解除 Marker 上的 Label(SDK 无官方清除 API,兜底隐藏并清引用) */
|
|
165
|
+
removeMarkerLabel(marker: OverlayHandle, label: OverlayHandle): void;
|
|
166
|
+
addLayer(map: MapHandle, layer: LayerHandle): void;
|
|
167
|
+
removeLayer(map: MapHandle, layer: LayerHandle): void;
|
|
168
|
+
addTileLayer(map: MapHandle, layer: LayerHandle): void;
|
|
169
|
+
removeTileLayer(map: MapHandle, layer: LayerHandle): void;
|
|
170
|
+
getTileLayer(map: MapHandle, mapType: string): LayerHandle | null;
|
|
171
|
+
addGeoJSONLayer(map: MapHandle, layer: LayerHandle): void;
|
|
172
|
+
removeGeoJSONLayer(map: MapHandle, layer: LayerHandle): void;
|
|
173
|
+
addDistrictLayer(map: MapHandle, layer: LayerHandle): void;
|
|
174
|
+
removeDistrictLayer(map: MapHandle, layer: LayerHandle): void;
|
|
175
|
+
addNormalLayer(map: MapHandle, layer: LayerHandle): void;
|
|
176
|
+
removeNormalLayer(map: MapHandle, layer: LayerHandle): void;
|
|
177
|
+
setTrafficOn(map: MapHandle): void;
|
|
178
|
+
setTrafficOff(map: MapHandle): void;
|
|
179
|
+
showOverlayContainer(map: MapHandle): void;
|
|
180
|
+
hideOverlayContainer(map: MapHandle): void;
|
|
181
|
+
openInfoWindow(map: MapHandle | OverlayHandle, iw: OverlayHandle, point?: Point): void;
|
|
182
|
+
closeInfoWindow(map: MapHandle | OverlayHandle): void;
|
|
183
|
+
openSimpleInfoWindow(map: MapHandle, iw: OverlayHandle, point: Point): void;
|
|
184
|
+
closeSimpleInfoWindow(map: MapHandle): void;
|
|
185
|
+
setMapStyle(map: MapHandle, config: unknown): void;
|
|
186
|
+
setMapStyleV2(map: MapHandle, options: unknown): void;
|
|
187
|
+
setTheme(map: MapHandle, theme: string, customVars?: Record<string, string>): void;
|
|
188
|
+
setCopyrightOffset(map: MapHandle, logo: unknown, cpy: unknown): void;
|
|
189
|
+
setDefaultCursor(map: MapHandle, cursor: string): void;
|
|
190
|
+
getDefaultCursor(map: MapHandle): string;
|
|
191
|
+
setDraggingCursor(map: MapHandle, cursor: string): void;
|
|
192
|
+
getDraggingCursor(map: MapHandle): string;
|
|
193
|
+
setOverlayMoveCursor(map: MapHandle, cursor: string): void;
|
|
194
|
+
startViewAnimation(map: MapHandle, viewAnimation: unknown): number;
|
|
195
|
+
pauseViewAnimation(map: MapHandle, viewAnimation?: unknown): void;
|
|
196
|
+
continueViewAnimation(map: MapHandle, viewAnimation?: unknown): void;
|
|
197
|
+
cancelViewAnimation(map: MapHandle, viewAnimation?: unknown): void;
|
|
198
|
+
getScreenshot(map: MapHandle): string;
|
|
199
|
+
isSupportEarth(map: MapHandle): boolean;
|
|
200
|
+
getEarth(map: MapHandle): unknown;
|
|
201
|
+
showEarthBoundary(map: MapHandle): void;
|
|
202
|
+
hideEarthBoundary(map: MapHandle): void;
|
|
203
|
+
setEarthMaxZoom(map: MapHandle, zoom: number): void;
|
|
204
|
+
setEarthMinZoom(map: MapHandle, zoom: number): void;
|
|
205
|
+
showIndoor(map: MapHandle, uid: string, floor: number): void;
|
|
206
|
+
setIndoor(map: MapHandle, uid: string, floor: number): void;
|
|
207
|
+
getIndoorInfo(map: MapHandle): unknown | null;
|
|
208
|
+
initIndoorLayer(map: MapHandle, opts?: unknown): unknown;
|
|
209
|
+
setNormalMapDisplay(map: MapHandle, display: boolean): void;
|
|
210
|
+
getVectorContainer(map: MapHandle): unknown;
|
|
211
|
+
showStreetLayer(map: MapHandle, show: boolean): void;
|
|
212
|
+
hideStreetLayer(map: MapHandle): void;
|
|
213
|
+
isStreetLayerShow(map: MapHandle): boolean;
|
|
214
|
+
showVectorStreetLayer(map: MapHandle): void;
|
|
215
|
+
hideVectorStreetLayer(map: MapHandle): void;
|
|
216
|
+
getLanguage(map: MapHandle): string;
|
|
217
|
+
changeLanguage(map: MapHandle, language: string): void;
|
|
218
|
+
enablePreferredLanguage(map: MapHandle, language: string): void;
|
|
219
|
+
disablePreferredLanguage(map: MapHandle): void;
|
|
220
|
+
setLock(map: MapHandle, lock: boolean): void;
|
|
221
|
+
setPrivateRegions(map: MapHandle, regions: unknown[]): void;
|
|
222
|
+
getPrivateRegions(map: MapHandle): unknown[];
|
|
223
|
+
setPrivateStatus(map: MapHandle, isOn: boolean): void;
|
|
224
|
+
getPrivateStatus(map: MapHandle): boolean;
|
|
225
|
+
setCustomArea(map: MapHandle, config: unknown): void;
|
|
226
|
+
addFocusMask(map: MapHandle, mask: unknown): void;
|
|
227
|
+
removeFocusMask(map: MapHandle, mask: unknown): void;
|
|
228
|
+
clearFocusMasks(map: MapHandle): void;
|
|
229
|
+
addCustomHtmlLayer(map: MapHandle, layer: unknown): void;
|
|
230
|
+
removeCustomHtmlLayer(map: MapHandle, layer: unknown): void;
|
|
231
|
+
addParkingSpot(map: MapHandle, layer: unknown): void;
|
|
232
|
+
removeParkingSpot(map: MapHandle, parking: unknown): void;
|
|
233
|
+
enableMapClick(map: MapHandle): void;
|
|
234
|
+
disableMapClick(map: MapHandle): void;
|
|
235
|
+
enable3DBuilding(map: MapHandle): void;
|
|
236
|
+
disable3DBuilding(map: MapHandle): void;
|
|
237
|
+
setPanorama(map: MapHandle, pano: unknown): void;
|
|
238
|
+
getPanorama(map: MapHandle): unknown;
|
|
239
|
+
setCurrentCity(map: MapHandle, city: string): void;
|
|
240
|
+
highResolutionEnabled(map: MapHandle): boolean;
|
|
241
|
+
addHotspot(map: MapHandle, hotspot: OverlayHandle): void;
|
|
242
|
+
removeHotspot(map: MapHandle, hotspot: OverlayHandle): void;
|
|
243
|
+
clearHotspots(map: MapHandle): void;
|
|
244
|
+
createMarker(position: Point, options?: unknown): OverlayHandle | null;
|
|
245
|
+
createLabel(content: unknown, options?: unknown): OverlayHandle | null;
|
|
246
|
+
createPolyline(path: Point[], options?: unknown): OverlayHandle | null;
|
|
247
|
+
createPolygon(path: Point[] | Point[][], options?: unknown): OverlayHandle | null;
|
|
248
|
+
createCircle(center: Point, radius: number, options?: unknown): OverlayHandle | null;
|
|
249
|
+
createRectangle(bounds: Bounds, options?: unknown): OverlayHandle | null;
|
|
250
|
+
/** controlPoints 为 SDK 必填位置参数:每两个路径点之间 1~2 个控制点,组数 = path.length - 1 */
|
|
251
|
+
createBezierCurve(path: Point[], controlPoints: Point[][], options?: unknown): OverlayHandle | null;
|
|
252
|
+
/**
|
|
253
|
+
* altitude 为 SDK 必填位置参数(棱柱高度,米)。
|
|
254
|
+
* path 支持单坐标串 Point[] 或多坐标串 Point[][](后者仅 constructor 支持,setPath 只接受单串)。
|
|
255
|
+
*/
|
|
256
|
+
createPrism(path: Point[] | Point[][], altitude: number, options?: unknown): OverlayHandle | null;
|
|
257
|
+
createMarker3D(position: Point, height: number, options?: unknown): OverlayHandle | null;
|
|
258
|
+
createGroundOverlay(bounds: Bounds, options?: unknown): OverlayHandle | null;
|
|
259
|
+
createGroundPoint(point: Point, options?: unknown): OverlayHandle | null;
|
|
260
|
+
createPointCollection(points: Point[], options?: unknown): OverlayHandle | null;
|
|
261
|
+
createInfoWindow(content: unknown, options?: unknown): OverlayHandle | null;
|
|
262
|
+
createSymbol(path: unknown, options?: unknown): OverlayHandle | null;
|
|
263
|
+
createIcon(url: string, size: Size, options?: unknown): OverlayHandle | null;
|
|
264
|
+
createIconSequence(symbol?: OverlayHandle, offset?: unknown, repeat?: string, fixedRotation?: boolean): OverlayHandle | null;
|
|
265
|
+
createHotspot(position: Point, options?: unknown): OverlayHandle | null;
|
|
266
|
+
createCustomOverlay(domCreate?: Function, options?: unknown): OverlayHandle | null;
|
|
267
|
+
setOverlayPosition(overlay: OverlayHandle, position: Point): void;
|
|
268
|
+
setOverlayPath(overlay: OverlayHandle, path: Point[] | Point[][]): void;
|
|
269
|
+
setOverlayOptions(overlay: OverlayHandle, options: unknown): void;
|
|
270
|
+
/**
|
|
271
|
+
* 读取 overlay 当前 option 的原始值快照,用于 prop 从有值变回 undefined 时还原。
|
|
272
|
+
* 只返回「SDK 提供 getter 且当前有值」的 key,其余 key 直接缺席——调用方据此判断哪些还原不了。
|
|
273
|
+
* 返回的是 SDK 原始对象(raw Icon / raw Size 等),只应交给 restoreOverlayOptions 写回。
|
|
274
|
+
*/
|
|
275
|
+
snapshotOverlayOptions(overlay: OverlayHandle, keys: string[]): Record<string, unknown>;
|
|
276
|
+
/**
|
|
277
|
+
* 把 snapshotOverlayOptions 取到的原始值写回 overlay。
|
|
278
|
+
* 返回未能还原的 key(SDK 无对应 setter 或调用抛错),调用方据此告警。
|
|
279
|
+
*/
|
|
280
|
+
restoreOverlayOptions(overlay: OverlayHandle, snapshot: Record<string, unknown>): string[];
|
|
281
|
+
/** Overlay 基类 show() — 显示覆盖物 */
|
|
282
|
+
showOverlay(overlay: OverlayHandle): void;
|
|
283
|
+
/** Overlay 基类 hide() — 隐藏覆盖物 */
|
|
284
|
+
hideOverlay(overlay: OverlayHandle): void;
|
|
285
|
+
/** Marker.openPlaceDetail — 打开地点详情窗口(仅 v4+) */
|
|
286
|
+
openPlaceDetail(marker: OverlayHandle, placeDetail: ServiceHandle): void;
|
|
287
|
+
/** Marker.closePlaceDetail — 关闭地点详情窗口(仅 v4+) */
|
|
288
|
+
closePlaceDetail(marker: OverlayHandle): void;
|
|
289
|
+
createNavigationControl(options?: unknown): ControlHandle | null;
|
|
290
|
+
createNavigationControl3D(options?: unknown): ControlHandle | null;
|
|
291
|
+
createScaleControl(options?: unknown): ControlHandle | null;
|
|
292
|
+
createOverviewMapControl(options?: unknown): ControlHandle | null;
|
|
293
|
+
createMapTypeControl(options?: unknown): ControlHandle | null;
|
|
294
|
+
createCopyrightControl(options?: unknown): ControlHandle | null;
|
|
295
|
+
createGeolocationControl(options?: unknown): ControlHandle | null;
|
|
296
|
+
createPanoramaControl(options?: unknown): ControlHandle | null;
|
|
297
|
+
createZoomControl(options?: unknown): ControlHandle | null;
|
|
298
|
+
createCityListControl(options?: unknown): ControlHandle | null;
|
|
299
|
+
createLocationControl(options?: unknown): ControlHandle | null;
|
|
300
|
+
createLogoControl(options?: unknown): ControlHandle | null;
|
|
301
|
+
createControl(options?: unknown): ControlHandle | null;
|
|
302
|
+
/** 自定义控件:domCreate 返回的 DOM 会被 initialize(map) 挂到地图容器上 */
|
|
303
|
+
createCustomControl(domCreate: () => HTMLElement, options?: unknown): ControlHandle | null;
|
|
304
|
+
createTileLayer(options?: unknown): LayerHandle | null;
|
|
305
|
+
createNormalLayer(options?: unknown): LayerHandle | null;
|
|
306
|
+
createGeoJSONLayer(options?: unknown): LayerHandle | null;
|
|
307
|
+
createDistrictLayer(options?: unknown): LayerHandle | null;
|
|
308
|
+
createTrafficLayer(options?: unknown): LayerHandle | null;
|
|
309
|
+
createCustomLayer(options?: unknown): LayerHandle | null;
|
|
310
|
+
createCanvasLayer(options?: unknown): LayerHandle | null;
|
|
311
|
+
createRasterTileLayer(options?: unknown): LayerHandle | null;
|
|
312
|
+
createWMSLayer(options?: unknown): LayerHandle | null;
|
|
313
|
+
createWMTSLayer(options?: unknown): LayerHandle | null;
|
|
314
|
+
createXYZLayer(options?: unknown): LayerHandle | null;
|
|
315
|
+
createMVTLayer(options?: unknown): LayerHandle | null;
|
|
316
|
+
createFeatureLayer(options?: unknown): LayerHandle | null;
|
|
317
|
+
createFillLayer(options?: unknown): LayerHandle | null;
|
|
318
|
+
createDOMLayer(options?: unknown): LayerHandle | null;
|
|
319
|
+
createPointIconLayer(options?: unknown): LayerHandle | null;
|
|
320
|
+
createPointShapeLayer(options?: unknown): LayerHandle | null;
|
|
321
|
+
createPanoramaCoverageLayer(options?: unknown): LayerHandle | null;
|
|
322
|
+
createLineLayer(options?: unknown): LayerHandle | null;
|
|
323
|
+
createPixelLayer(options?: unknown): LayerHandle | null;
|
|
324
|
+
createBaiduLayer(options?: unknown): LayerHandle | null;
|
|
325
|
+
createThreeLayer(options?: unknown): LayerHandle | null;
|
|
326
|
+
createContextMenu(options?: unknown): OverlayHandle | null;
|
|
327
|
+
createMenuItem(text: string, callback: (point?: {
|
|
328
|
+
lng: number;
|
|
329
|
+
lat: number;
|
|
330
|
+
}) => void, options?: unknown): OverlayHandle | null;
|
|
331
|
+
addMenuItem(menu: OverlayHandle, item: OverlayHandle, insertIndex?: number): void;
|
|
332
|
+
removeMenuItem(menu: OverlayHandle, item: OverlayHandle): void;
|
|
333
|
+
createPanorama(container: HTMLElement, options?: unknown): MapHandle | null;
|
|
334
|
+
createPanoramaLabel(options?: unknown): OverlayHandle | null;
|
|
335
|
+
destroyPanorama(handle: MapHandle): void;
|
|
336
|
+
createLocalSearch(location: unknown, options?: unknown): ServiceHandle;
|
|
337
|
+
createGeocoder(): ServiceHandle;
|
|
338
|
+
createDrivingRoute(options?: unknown): ServiceHandle;
|
|
339
|
+
createWalkingRoute(options?: unknown): ServiceHandle;
|
|
340
|
+
createRidingRoute(options?: unknown): ServiceHandle;
|
|
341
|
+
createTransitRoute(options?: unknown): ServiceHandle;
|
|
342
|
+
createBusLineSearch(options?: unknown): ServiceHandle;
|
|
343
|
+
createAutocomplete(options?: unknown): ServiceHandle;
|
|
344
|
+
createBoundary(): ServiceHandle;
|
|
345
|
+
createGeolocation(options?: unknown): ServiceHandle;
|
|
346
|
+
createLocalCity(options?: unknown): ServiceHandle;
|
|
347
|
+
createPlaceDetail(options?: unknown): ServiceHandle;
|
|
348
|
+
createConvertor(): ServiceHandle;
|
|
349
|
+
createPanoramaService(): ServiceHandle;
|
|
350
|
+
createTruckRoute(options?: unknown): ServiceHandle;
|
|
351
|
+
searchService(service: ServiceHandle, query: unknown, callbacks: {
|
|
352
|
+
onSuccess?: (data: unknown) => void;
|
|
353
|
+
onError?: (err: Error) => void;
|
|
354
|
+
}): () => void;
|
|
355
|
+
getServiceResults(service: ServiceHandle): unknown;
|
|
356
|
+
addEventListener(target: MapHandle | OverlayHandle | ControlHandle | LayerHandle, type: string, handler: (raw: unknown) => void): () => void;
|
|
357
|
+
removeEventListener(target: MapHandle | OverlayHandle | ControlHandle | LayerHandle, type: string, handler: (raw: unknown) => void): void;
|
|
358
|
+
}
|
|
359
|
+
export type { LoadKeyComponents, LayerKind };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { BMapVersion, Capability, UnsupportedBehavior } from '../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 不支持能力异常。
|
|
5
|
+
* 在 throw 策略下抛此异常;用户可用 try/catch 或 ErrorBoundary 捕获。
|
|
6
|
+
*/
|
|
7
|
+
export declare class UnsupportedCapabilityError extends Error {
|
|
8
|
+
capability: Capability;
|
|
9
|
+
version: BMapVersion;
|
|
10
|
+
constructor(capability: Capability, version: BMapVersion);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 报告不支持的能力。根据 behavior:
|
|
14
|
+
* - 'throw':抛 UnsupportedCapabilityError
|
|
15
|
+
* - 'warn':dev console.warn,正常返回(调用方返回兜底值)
|
|
16
|
+
* - 'ignore':静默,正常返回(调用方返回兜底值)
|
|
17
|
+
*
|
|
18
|
+
* 只用于「确实不支持」:能力矩阵里没有,或原生成员不存在。
|
|
19
|
+
* 「成员存在但执行时抛错」请走 reportCallFailure,不要塞到这里 ——
|
|
20
|
+
* 那会把真实的运行时错误说成版本问题,排障时反而被误导。
|
|
21
|
+
*
|
|
22
|
+
* 用于命令(返回 void):throw 抛错;warn/ignore noop。
|
|
23
|
+
*/
|
|
24
|
+
export declare function reportUnsupported(capability: Capability, version: BMapVersion, behavior: UnsupportedBehavior): void;
|
|
25
|
+
/**
|
|
26
|
+
* 判断一个错误是不是「成员根本不存在」。
|
|
27
|
+
*
|
|
28
|
+
* 依据的是 JS 引擎自己产出的 TypeError 文案(`x is not a function` /
|
|
29
|
+
* `x is not a constructor`),V8/JSC/SpiderMonkey 都是这套措辞;不是匹配 SDK
|
|
30
|
+
* 的字符串,所以 SDK 压缩混淆换版本也不会失效。判错的最坏后果只是日志分类不准,
|
|
31
|
+
* 不会引入新的失败路径。
|
|
32
|
+
*/
|
|
33
|
+
export declare function isMissingMember(e: unknown): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* 调用原生 API 失败时的统一出口,按错误性质分流:
|
|
36
|
+
* - 成员不存在 → reportUnsupported,语义是「这个版本没这能力」
|
|
37
|
+
* - 成员存在但抛错(参数非法、SDK 内部空指针、销毁竞态……)→ debugWarn 带上原始错误
|
|
38
|
+
*
|
|
39
|
+
* 后者刻意不抛:behavior='throw' 的语义是「能力不支持时抛」,而且这些 catch 大多在
|
|
40
|
+
* React effect / cleanup 里,抛出会连带整棵树。
|
|
41
|
+
*/
|
|
42
|
+
export declare function reportCallFailure(capability: Capability, version: BMapVersion, behavior: UnsupportedBehavior, error: unknown): void;
|
|
43
|
+
/**
|
|
44
|
+
* Getter 不支持时的兜底。先 reportUnsupported,然后返回类型断言的兜底值。
|
|
45
|
+
* - number 类型建议返回 NaN(业务可用 Number.isNaN 检测)
|
|
46
|
+
* - 对象类型字段为 undefined
|
|
47
|
+
*
|
|
48
|
+
* 调用方需根据语义传 fallback:
|
|
49
|
+
* return unsupportedValue('getHeading', '3.0', behavior, NaN);
|
|
50
|
+
*/
|
|
51
|
+
export declare function unsupportedValue<T>(capability: Capability, version: BMapVersion, behavior: UnsupportedBehavior, fallback: T): T;
|
|
52
|
+
/**
|
|
53
|
+
* tryOp 工具:在 throw 模式下捕获 UnsupportedCapabilityError,转成 Result。
|
|
54
|
+
* 业务想优雅处理时使用:
|
|
55
|
+
* const r = tryOp(() => mapRef.flyTo(...));
|
|
56
|
+
* if (!r.ok) { /* fallback *\/ }
|
|
57
|
+
*/
|
|
58
|
+
export type OpResult<T> = {
|
|
59
|
+
ok: true;
|
|
60
|
+
value: T;
|
|
61
|
+
} | {
|
|
62
|
+
ok: false;
|
|
63
|
+
reason: 'unsupported';
|
|
64
|
+
capability: Capability;
|
|
65
|
+
};
|
|
66
|
+
export declare function tryOp<T>(fn: () => T): OpResult<T>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UnsupportedBehavior } from '../types';
|
|
2
|
+
import { BMapDriver } from './types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* v3 Driver — 3.0 适配。
|
|
6
|
+
* - 复用 v4 driver 的通用骨架
|
|
7
|
+
* - 3.0-only 方法真实实现
|
|
8
|
+
* - 4.0-only 方法走 unsupported
|
|
9
|
+
* - capabilities 用 v3 矩阵(与 v4 区分)
|
|
10
|
+
*/
|
|
11
|
+
export declare function createV3Driver(rawSDK: any, opts: {
|
|
12
|
+
unsupportedBehavior: UnsupportedBehavior;
|
|
13
|
+
}): BMapDriver;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BMapVersion, UnsupportedBehavior } from '../types';
|
|
2
|
+
import { BMapDriver } from './types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* v4 Driver — 4.0 baseline 实现。
|
|
6
|
+
* 直接 1:1 调用 window.BMap 上的类与方法;缺的能力(3.0-only)按 unsupportedBehavior 处理。
|
|
7
|
+
*
|
|
8
|
+
* opts.version 只影响日志文案(v3Driver 复用本实现,
|
|
9
|
+
* 不传的话 3.0 会话里也会打成 "JSAPI 4.0")。
|
|
10
|
+
* capabilities 仍固定取 4.0 矩阵:v3Driver 依赖这一点绕过能力检查直建 v3-only 的类。
|
|
11
|
+
*/
|
|
12
|
+
export declare function createV4Driver(rawSDK: any, opts: {
|
|
13
|
+
unsupportedBehavior: UnsupportedBehavior;
|
|
14
|
+
version?: BMapVersion;
|
|
15
|
+
}): BMapDriver;
|