-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
MapViewTypes.ts
74 lines (63 loc) · 2.33 KB
/
MapViewTypes.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
import type {ReactNode} from 'react';
import type {StyleProp, ViewStyle} from 'react-native';
type MapViewProps = {
// Public access token to be used to fetch map data from Mapbox.
accessToken: string;
// Style applied to MapView component. Note some of the View Style props are not available on ViewMap
style: StyleProp<ViewStyle>;
// Link to the style JSON document.
styleURL?: string;
// Whether map can tilt in the vertical direction.
pitchEnabled?: boolean;
// Padding to apply when the map is adjusted to fit waypoints and directions
mapPadding?: number;
// Initial coordinate and zoom level
initialState?: InitialState;
// Locations on which to put markers
waypoints?: WayPoint[];
// List of coordinates which together forms a direction.
directionCoordinates?: Array<[number, number]>;
// Callback to call when the map is idle / ready.
onMapReady?: () => void;
// Whether the map is interactable or not
interactive?: boolean;
};
type DirectionProps = {
// Coordinates of points that constitute the direction
coordinates: Array<[number, number]>;
};
type PendingMapViewProps = {
/** Title message below the icon */
title?: string;
/** Subtitle message below the title */
subtitle?: string;
/** Style applied to PendingMapView */
style?: StyleProp<ViewStyle>;
/** Whether the size of the route pending icon is smaller. */
isSmallerIcon?: boolean;
};
// Initial state of the map
type InitialState = {
// Coordinate on which to center the map
location: [number, number];
zoom: number;
};
// Waypoint to be displayed on the map
type WayPoint = {
id: string;
coordinate: [number, number];
markerComponent: () => ReactNode;
};
// Style used for the line that displays direction
type DirectionStyle = {
width?: number;
color?: string;
};
// Represents a handle to interact with a map view.
type MapViewHandle = {
// Fly to a location on the map
flyTo: (location: [number, number], zoomLevel: number, animationDuration?: number) => void;
// Fit the map view to a bounding box
fitBounds: (ne: [number, number], sw: [number, number], paddingConfig?: number | number[], animationDuration?: number) => void;
};
export type {DirectionStyle, WayPoint, MapViewProps, DirectionProps, PendingMapViewProps, MapViewHandle};