forked from krzysztofch19/react-native-maps-osmdroid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
438 lines (380 loc) · 14.1 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
declare module "react-native-maps" {
import * as React from 'react';
import {
Animated,
ImageRequireSource,
ImageURISource,
NativeSyntheticEvent,
ViewProperties
} from 'react-native';
export interface Region {
latitude: number;
longitude: number;
latitudeDelta: number;
longitudeDelta: number;
}
export interface LatLng {
latitude: number;
longitude: number;
}
export interface Camera {
center: LatLng;
heading: number;
pitch: number;
zoom: number;
altitude: number;
}
export interface Point {
x: number;
y: number;
}
// helper interface
export interface MapEvent<T = {}> extends NativeSyntheticEvent<T & {
coordinate: LatLng;
position: Point;
}> {}
export type LineCapType = 'butt' | 'round' | 'square';
export type LineJoinType = 'miter' | 'round' | 'bevel';
// =======================================================================
// AnimatedRegion
// =======================================================================
interface AnimatedRegionTimingConfig extends Animated.AnimationConfig, Partial<Region> {
easing?: (value: number) => number;
duration?: number;
delay?: number;
}
interface AnimatedRegionSpringConfig extends Animated.AnimationConfig, Partial<Region> {
overshootClamping?: boolean;
restDisplacementThreshold?: number;
restSpeedThreshold?: number;
velocity?: number | Point;
bounciness?: number;
speed?: number;
tension?: number;
friction?: number;
stiffness?: number;
mass?: number;
damping?: number;
}
export class AnimatedRegion extends Animated.AnimatedWithChildren {
latitude: Animated.Value
longitude: Animated.Value
latitudeDelta: Animated.Value
longitudeDelta: Animated.Value
constructor(region?: Region);
setValue(value: Region): void;
setOffset(offset: Region): void;
flattenOffset(): void;
stopAnimation(callback?: (region: Region) => void): void;
addListener(callback: (region: Region) => void): string;
removeListener(id: string): void;
spring(config: AnimatedRegionSpringConfig): Animated.CompositeAnimation;
timing(config: AnimatedRegionTimingConfig): Animated.CompositeAnimation;
}
// =======================================================================
// MapView (default export)
// =======================================================================
/**
* takeSnapshot options
*/
export interface SnapshotOptions {
/** optional, when omitted the view-width is used */
width?: number;
/** optional, when omitted the view-height is used */
height?: number;
/** __iOS only__, optional region to render */
region?: Region;
/** image formats, defaults to 'png' */
format?: 'png' | 'jpg';
/** image quality: 0..1 (only relevant for jpg, default: 1) */
quality?: number;
/** result types, defaults to 'file' */
result?: 'file' | 'base64';
}
/**
* onUserLocationChange parameters
*/
export interface EventUserLocation extends NativeSyntheticEvent<{}> {
nativeEvent: {
coordinate: {
latitude: number,
longitude: number,
altitude: number,
timestamp: number,
accuracy: number,
speed: number,
isFromMockProvider: boolean,
},
};
}
/**
* Map style elements.
* @see https://developers.google.com/maps/documentation/ios-sdk/styling#use_a_string_resource
* @see https://developers.google.com/maps/documentation/android-api/styling
*/
export type MapStyleElement = {
featureType?: string,
elementType?: string,
stylers: object[],
};
export type EdgePadding = {
top: Number,
right: Number,
bottom: Number,
left: Number,
};
export type EdgeInsets = {
top: Number,
right: Number,
bottom: Number,
left: Number,
};
export type KmlMarker = {
id: String,
title: String,
description: String,
coordinate: LatLng,
position: Point,
};
/**
* onKmlReady parameter
*/
export interface KmlMapEvent extends NativeSyntheticEvent<{ markers: KmlMarker[] }> {
}
type MapTypes = 'standard' | 'satellite' | 'hybrid' | 'terrain' | 'none' | 'mutedStandard';
export interface MapViewProps extends ViewProperties {
provider?: 'google' | null;
customMapStyle?: MapStyleElement[];
customMapStyleString?: string;
showsUserLocation?: boolean;
userLocationAnnotationTitle?: string;
showsMyLocationButton?: boolean;
followsUserLocation?: boolean;
showsPointsOfInterest?: boolean;
showsCompass?: boolean;
zoomEnabled?: boolean;
zoomControlEnabled?: boolean;
rotateEnabled?: boolean;
cacheEnabled?: boolean;
loadingEnabled?: boolean;
loadingBackgroundColor?: string;
loadingIndicatorColor?: string;
scrollEnabled?: boolean;
pitchEnabled?: boolean;
toolbarEnabled?: boolean;
moveOnMarkerPress?: boolean;
showsScale?: boolean;
showsBuildings?: boolean;
showsTraffic?: boolean;
showsIndoors?: boolean;
showsIndoorLevelPicker?: boolean;
mapType?: MapTypes;
region?: Region;
initialRegion?: Region;
camera?: Camera;
initialCamera?: Camera;
liteMode?: boolean;
mapPadding?: EdgePadding;
maxDelta?: number;
minDelta?: number;
legalLabelInsets?: EdgeInsets;
onMapReady?: () => void;
onKmlReady?: (values: KmlMapEvent) => void;
onRegionChange?: (region: Region) => void;
onRegionChangeComplete?: (region: Region) => void;
onPress?: (event: MapEvent) => void;
onLongPress?: (event: MapEvent) => void;
onUserLocationChange?: (event: EventUserLocation) => void;
onPanDrag?: (event: MapEvent) => void;
onPoiClick?: (event: MapEvent<{ placeId: string, name: string }>) => void;
onMarkerPress?: (event: MapEvent<{ action: 'marker-press', id: string }>) => void;
onMarkerSelect?: (event: MapEvent<{ action: 'marker-select', id: string }>) => void;
onMarkerDeselect?: (event: MapEvent<{ action: 'marker-deselect', id: string }>) => void;
onCalloutPress?: (event: MapEvent<{ action: 'callout-press' }>) => void;
onMarkerDragStart?: (event: MapEvent) => void;
onMarkerDrag?: (event: MapEvent) => void;
onMarkerDragEnd?: (event: MapEvent) => void;
minZoomLevel?: number;
maxZoomLevel?: number;
kmlSrc?: string;
}
export default class MapView extends React.Component<MapViewProps, any> {
getCamera(): Promise<Camera>;
setCamera(camera: Partial<Camera>): void;
animateCamera(camera: Partial<Camera>, opts?: {duration?: number}): void;
animateToNavigation(location: LatLng, bearing: number, angle: number, duration?: number): void;
animateToRegion(region: Region, duration?: number): void;
animateToCoordinate(latLng: LatLng, duration?: number): void;
animateToBearing(bearing: number, duration?: number): void;
animateToViewingAngle(angle: number, duration?: number): void;
fitToElements(animated: boolean): void;
fitToSuppliedMarkers(markers: string[], options?: { edgePadding?: EdgePadding, animated?: boolean }): void;
fitToCoordinates(coordinates?: LatLng[], options?: { edgePadding?: EdgePadding, animated?: boolean }): void;
setMapBoundaries(northEast: LatLng, southWest: LatLng): void;
getMapBoundaries(): {northEast: LatLng; southWest: LatLng};
takeSnapshot(options?: SnapshotOptions): Promise<string>;
}
export class MapViewAnimated extends MapView {
}
// =======================================================================
// Marker
// =======================================================================
export interface MarkerProps extends ViewProperties {
identifier?: string;
reuseIdentifier?: string;
title?: string;
description?: string;
image?: ImageURISource | ImageRequireSource;
opacity?: number;
pinColor?: string;
coordinate: LatLng | AnimatedRegion;
centerOffset?: Point;
calloutOffset?: Point;
anchor?: Point;
calloutAnchor?: Point;
flat?: boolean;
draggable?: boolean;
tracksViewChanges?: boolean
tracksInfoWindowChanges?: boolean
stopPropagation?: boolean
onPress?: (event: MapEvent<{ action: 'marker-press', id: string }>) => void;
onSelect?: (event: MapEvent<{ action: 'marker-select', id: string }>) => void;
onDeselect?: (event: MapEvent<{ action: 'marker-deselect', id: string }>) => void;
onCalloutPress?: (event: MapEvent<{ action: 'callout-press' }>) => void;
onDragStart?: (event: MapEvent) => void;
onDrag?: (event: MapEvent) => void;
onDragEnd?: (event: MapEvent) => void;
rotation?: number;
zIndex?: number;
}
export class Marker extends React.Component<MarkerProps, any> {
/**
* Shows the callout for this marker
*/
showCallout(): void;
/**
* Hides the callout for this marker
*/
hideCallout(): void;
/**
* Animates marker movement.
* __Android only__
*/
animateMarkerToCoordinate(coordinate: LatLng, duration?: number): void;
}
export class MarkerAnimated extends Marker {
}
// =======================================================================
// Callout
// =======================================================================
export interface MapCalloutProps extends ViewProperties {
tooltip?: boolean;
onPress?: (event: MapEvent<{ action: 'callout-press' }>) => void;
}
export class Callout extends React.Component<MapCalloutProps, any> {
}
// =======================================================================
// Polyline
// =======================================================================
export interface MapPolylineProps extends ViewProperties {
coordinates: LatLng[];
onPress?: (event: MapEvent) => void;
tappable?: boolean;
fillColor?: string;
strokeWidth?: number;
strokeColor?: string;
strokeColors?: string[];
zIndex?: number;
lineCap?: LineCapType;
lineJoin?: LineJoinType;
miterLimit?: number;
geodesic?: boolean;
lineDashPhase?: number;
lineDashPattern?: number[];
}
export class Polyline extends React.Component<MapPolylineProps, any> {
}
// =======================================================================
// Polygon
// =======================================================================
export interface MapPolygonProps extends ViewProperties {
coordinates: LatLng[];
holes?: LatLng[][];
onPress?: (event: MapEvent) => void;
tappable?: boolean;
strokeWidth?: number;
strokeColor?: string;
fillColor?: string;
zIndex?: number;
lineCap?: LineCapType;
lineJoin?: LineJoinType;
miterLimit?: number;
geodesic?: boolean;
lineDashPhase?: number;
lineDashPattern?: number[];
}
export class Polygon extends React.Component<MapPolygonProps, any> {
}
// =======================================================================
// Circle
// =======================================================================
export interface MapCircleProps extends ViewProperties {
center: LatLng;
radius: number;
onPress?: (event: MapEvent) => void;
strokeWidth?: number;
strokeColor?: string;
fillColor?: string;
zIndex?: number;
lineCap?: LineCapType;
lineJoin?: LineJoinType;
miterLimit?: number;
lineDashPhase?: number;
lineDashPattern?: number[];
}
export class Circle extends React.Component<MapCircleProps, any> {
}
// =======================================================================
// UrlTile & LocalTile
// =======================================================================
export interface MapUrlTileProps extends ViewProperties {
urlTemplate: string;
maximumZ?: number;
zIndex?: number;
tileSize?: number;
}
export class UrlTile extends React.Component<MapUrlTileProps, any> {
}
export interface MapLocalTileProps extends ViewProperties {
pathTemplate: string;
tileSize?: number;
zIndex?: number;
}
export class LocalTile extends React.Component<MapLocalTileProps, any> {
}
// =======================================================================
// Overlay
// =======================================================================
type Coordinate = [number, number]
export interface MapOverlayProps extends ViewProperties {
image?: ImageURISource | ImageRequireSource;
bounds: [Coordinate, Coordinate];
}
export class Overlay extends React.Component<MapOverlayProps, any> {
}
export class OverlayAnimated extends Overlay {
}
// =======================================================================
// Constants
// =======================================================================
export const MAP_TYPES: {
STANDARD: MapTypes,
SATELLITE: MapTypes,
HYBRID: MapTypes,
TERRAIN: MapTypes,
NONE: MapTypes,
MUTEDSTANDARD: MapTypes,
}
export const PROVIDER_DEFAULT: null;
export const PROVIDER_GOOGLE: 'google';
}