forked from lovebing/react-native-baidu-map
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
470 lines (392 loc) · 9.46 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
import { Component } from "react";
import { ImageSourcePropType, ViewProps } from "react-native";
/**
* Baidu Map SDK modules and views for React Native(Android & iOS), support react native 0.61+.
*/
declare namespace ReactNativeBaiduMap {
/**
* 坐标对象
*/
export interface Location {
/**
* 纬度
*/
latitude: number;
/**
* 纬度
*/
longitude: number;
}
export interface Stroke {
width: number;
color: string;
}
/**
* 颜色渐变对象
*/
export interface Gradient {
colors: Array<string>;
startPoints: Array<number>
}
type CommonCallBack<T> = (l: T) => void;
/**
* onMapStatusChange 回调事件参数
*/
export interface onMapStatusChangeEvent {
overlook: number;
target: Location & {
zoom: number;
};
}
/**
* onMarkerClick 回调事件参数
*/
export interface onMarkerClickEvent {
position: Location;
title?: string;
}
export interface MapViewProps extends ViewProps {
/**
* @default true
* @supported Android only
*/
zoomControlsVisible?: boolean;
/**
* @default false
*/
trafficEnabled?: boolean;
/**
* @default false
*/
baiduHeatMapEnabled?: boolean;
/**
* 允许手势缩放
* @default true
*/
zoomGesturesEnabled?: boolean;
/**
* 允许拖动
* @default true
*/
scrollGesturesEnabled?: boolean;
/**
* NONE: 0; NORMAL: 1; SATELLITE: 2;
* @default 1
*/
mapType?: 0 | 1 | 2;
/**
* @default 10
*/
zoom?: number;
/**
* 是否显示定位
* @default false
*/
showsUserLocation?: boolean;
/**
* 定位信息 {latitude: 0, longitude: 0}
* @default null
*/
locationData?: Location;
/**
* 地图默认中心点
* @default null
*/
center?: Location;
/**
* @default undefined
* @supported Android only
*/
onMapStatusChangeStart?: Function;
/**
* @default undefined
*/
onMapStatusChange?: CommonCallBack<onMapStatusChangeEvent>;
/**
* @default undefined
* @supported Android only
*/
onMapStatusChangeFinish?: Function;
/**
* @default undefined
*/
onMapLoaded?: Function;
/**
* @default undefined
*/
onMapClick?: CommonCallBack<Location>;
/**
* @default undefined
*/
onMapDoubleClick?: Function;
/**
* @default undefined
*/
onMarkerClick?: CommonCallBack<onMarkerClickEvent>;
/**
* @default undefined
*/
onMapPoiClick?: Function;
}
export class MapView extends Component<MapViewProps> {}
export namespace Overlay {
export interface MarkerProps extends ViewProps {
/**
* @default undefined
*/
title?: string;
/**
* @default {latitude: 0, longitude: 0}
*/
location: Location;
/**
* @default null
*/
perspective?: boolean;
/**
* @default null
*/
flat?: boolean;
/**
* @default 0
*/
rotate?: number;
/**
* icon 图片,同 `Image` 的 source 属性
* @default null
*/
icon?: ImageSourcePropType;
/**
* 动画效果:drop/grow/jump (iOS 仅支持 drop)
*/
animateType?: string;
/**
* @default 0
*/
alpha?: number;
}
export class Marker extends Component<MarkerProps> {}
export interface ClusterProps extends ViewProps {}
export class Cluster extends Component<ClusterProps> {}
export interface ArcProps extends ViewProps {
/**
* @default {width: 5, color: 'AA000000'}
*/
stroke: Stroke;
/**
* 数值长度必须为 3
*/
points: [Location, Location, Location];
/**
* 是否为虚线,仅 iOS
*/
dash: boolean;
}
export class Arc extends Component<ArcProps> {
/**
* @default 1400
*/
radius?: number;
/**
* @default '000000FF'
*/
fillColor?: string;
/**
* @default {width: 5, color: 'AA000000'}
*/
stroke?: {
width: number;
color: string;
};
center: Location;
}
export interface CircleProps extends ViewProps {
radius: number;
fillColor: string;
stroke: Stroke;
center: Location;
}
export class Circle extends Component<CircleProps> {}
export interface PolylineProps extends ViewProps {
points: Location[];
stroke: Stroke;
}
export class Polyline extends Component<PolylineProps> {}
export interface PolygonProps extends ViewProps {
points: Location[];
/**
* 8位(AARRGGBB)
* @default 'AAFFFF00'
*/
fillColor?: string;
/**
* color: 8位(AARRGGBB)
* @default {width: 5, color: 'AA00FF00'}
*/
stroke?: { width: number; color: string };
}
export class Polygon extends Component<PolygonProps> {}
export interface TextProps extends ViewProps {
text: string;
fontSize?: number;
fontColor?: string;
bgColor?: string;
rotate?: number;
location: Location;
}
export class Text extends Component<TextProps> {}
export interface InfoWindowProps extends ViewProps {
/**
* 相对于 point 在 y 轴的偏移量,仅 Android
*/
offsetY: number;
}
export class InfoWindow extends Component<InfoWindowProps> {}
export interface HeatMapProps extends ViewProps {
points: Array<Location>;
gradient: Gradient;
}
/**
* 自定义热力图
*/
export class HeatMap extends Component<HeatMapProps> {}
}
export namespace Geolocation {
export type CoorType = "bd09ll" | "gcj02";
/**
* 经纬度查询地址详情
* @param lat 纬度
* @param lng 经度
*/
export function reverseGeoCode(
lat: number,
lng: number
): Promise<{
address: string;
province: string;
cityCode: string;
city: string;
district: string;
streetName: string;
streetNumber: string;
}>;
/**
* GPS 的经纬度查询地址详情
* @param lat 纬度
* @param lng 经度
*/
export function reverseGeoCodeGPS(
lat: number,
lng: number
): Promise<{
address: string;
province: string;
cityCode: string;
city: string;
district: string;
streetName: string;
streetNumber: string;
}>;
/**
* 地址转换为坐标
* @param city 城市
* @param addr 地址
*/
export function geocode(city: string, addr: string): Promise<Location>;
/**
* 获取当前定位信息
* @param coorType 定位类型
*/
export function getCurrentPosition(
coorType?: CoorType
): Promise<{
latitude: number;
longitude: number;
address: string;
province: string;
cityCode: string;
city: string;
district: string;
streetName: string;
streetNumber: string;
}>;
/**
* 开始持续定位
* @param listener 持续定位触发的监听函数
* @param coorType 定位类型
* @exports
* startLocating(() => { console.log() }, 'bd09ll');
*/
export function startLocating(listener: Function, coorType: CoorType): void;
/**
* 停止持续定位
*/
export function stopLocating(): void;
}
/**
* 两个坐标的距离
*/
export namespace GetDistance {
/**
* 计算两个坐标的距离
* @param l1 坐标1
* @param l2 坐标2
* @example
* const d = getLocationDistance({latitude: 0.0, longitude: 0.0}, {latitude: 0.0, longitude: 0.0});
* console.log(d.distance);
*/
export function getLocationDistance(
l1: Location,
l2: Location
): Promise<{
distance: number;
}>;
}
/**
* 调起百度地图客户端 iOS:必须在 Info.plist 中进行如下配置,否则不能调起百度地图客户端
* ```
* <key>LSApplicationQueriesSchemes</key>
* <array>
* <string>baidumap</string>
* </array>
* ```
*/
export namespace MapApp {
export interface OpenLocation extends Location {
name: string;
}
/**
* 调起百度地图驾车规划
* @param sl 起点坐标
* @param el 终点坐标
* @example openDrivingRoute({latitude: 0.0, longitude: 0.0, name: ''}, {latitude: 0.0, longitude: 0.0, name: ''})
*/
export function openDrivingRoute(sl: OpenLocation, el: OpenLocation): void;
/**
* 调起百度地图公交路线
* @param sl 起点坐标
* @param el 终点坐标
* @example openTransitRoute({latitude: 0.0, longitude: 0.0, name: ''}, {latitude: 0.0, longitude: 0.0, name: ''})
*/
export function openTransitRoute(sl: OpenLocation, el: OpenLocation): void;
/**
* 调起百度地图步行路线
* @param sl 起点坐标
* @param el 终点坐标
* @example openWalkNavi({latitude: 0.0, longitude: 0.0, name: ''}, {latitude: 0.0, longitude: 0.0, name: ''})
*/
export function openWalkNavi(sl: OpenLocation, el: OpenLocation): void;
}
export namespace BaiduMapManager {
/**
* iOS 初始化 SDK
* @param appKey
*/
export function initSDK(appKey: string): void;
/**
* 是否有定位权限
*/
export function hasLocationPermission(): Promise<boolean>;
}
}
export = ReactNativeBaiduMap;