xref: /expo/packages/expo-maps/src/Common.types.ts (revision ee0de234)
1/**
2 * Basic point type for representing a coordinate on a map.
3 */
4export type Point = {
5  /**
6   * The latitude of the point in degrees. Use decimal degrees as opposed to degrees/minutes/seconds.
7   * @required
8   */
9  latitude: number;
10  /**
11   * The longitude of the point in degrees. Use decimal degrees as opposed to degrees/minutes/seconds.
12   * @required
13   */
14  longitude: number;
15};
16
17/**
18 * Type for representing width and height on a map using latitude and longitude.
19 */
20export type LatLngDelta = {
21  /**
22   * The north-to-south distance.
23   * @required
24   */
25  latitudeDelta: number;
26  /**
27   * The east-to-west distance.
28   * @required
29   */
30  longitudeDelta: number;
31};
32
33/**
34 * Generic object that associates numerical data with a georgaphic coordinate.
35 */
36export type PointWithData = Point & {
37  /**
38   * Numerical data associated with the point. (optional)
39   * @default 1
40   */
41  data?: number;
42};
43
44/**
45 * PatternItem is used to define a repeating pattern for polyline and polygon line.
46 * PatternItem with type `stroke` and length 0 will represent a dot.
47 * Use an array of PatternItem to define a pattern.
48 */
49export type PatternItem = {
50  /**
51   * The type of the pattern item.
52   * * `'stroke'` - rendered line segment
53   * * `'gap'` - transparent gap between pattern items
54   * @required
55   */
56  type: 'stroke' | 'gap';
57  /**
58   * Length of the pattern item in pixels.
59   * @required
60   */
61  length: number;
62};
63
64export type CameraPosition = {
65  /**
66   * The location that the camera is pointing at.
67   * @required
68   */
69  target: Point;
70
71  /**
72   * The Direction that the camera is pointing in, in degrees clockwise from north
73   * @required
74   */
75  bearing: number;
76
77  /**
78   * The angle, in degrees, of the camera angle from the nadir (directly facing the Earth).
79   * @required
80   */
81
82  tilt: number;
83
84  /**
85   * Zoom level near the center of the screen.
86   * @platform iOS: Google maps only.
87   * @platform Android: Supported
88   */
89  zoom: number;
90
91  /**
92   * The amount of north-to-south distance (measured in degrees) to display on the map.
93   * @required for Apple Maps Only
94   */
95  latitudeDelta: number;
96
97  /**
98   * The amount of east-to-west distance (measured in degrees) to display for the map region.
99   * @required for Apple Maps Only
100   */
101  longitudeDelta: number;
102};
103
104/**
105 * Information about animation of the camera, contains target position and animation parameters.
106 * Camera will animate only the values which have been set, unset parameters won't be affected
107 *
108 * Note: If latLngDelta is set the camera move is going to ignore the zoom,
109 * tilt and bearing properties.Instead the camera will move to a smallest view containing a rectangle
110 * created around the center point by the deltas.
111 */
112export type CameraMove = {
113  /**
114   * Location to which the camera should animate. This will be in the center of the view
115   */
116  target?: Point;
117
118  /**
119   * Bearing to which the camera should animate.
120   */
121  bearing?: number;
122
123  /**
124   * Tilt to which the camera should animate.
125   */
126
127  tilt?: number;
128
129  /**
130   * Zoom to which the camera should animate.
131   */
132  zoom?: number;
133
134  latLngDelta?: LatLngDelta;
135
136  /**
137   * Duration in milliseconds of the animation
138   * @default 1000
139   */
140  duration?: number;
141  /**
142   * When true camera will smoothly animate it's position over the time provided in `duration` prop.
143   * Otherwise the camera will instantly move to provided position
144   * @default true
145   */
146  animate?: boolean;
147};
148
149/**
150 * Type describing points of interest on the map
151 */
152export type PointOfInterest = {
153  /**
154   * Position of the point of interest
155   * @required
156   */
157  position: Point;
158  /**
159   * Name of the point of interest
160   * @required
161   */
162  name: string;
163  /**
164   * Unique ID of the point of interest
165   * @required
166   */
167  placeId: string;
168};
169
170/**
171 * Type describing a marker (pin) placed on the map
172 */
173export type Marker = {
174  /**
175   * Id given to the marker
176   */
177  id: string;
178  /**
179   * Position of the marker
180   * @required
181   */
182  position: Point;
183};
184
185export type MapCluster = {
186  /**
187   * ID of the cluster
188   */
189  id: string;
190  /**
191   * Position of the point of the cluster
192   * @required
193   */
194  position: Point;
195};
196
197export type UserLocation = {
198  /**
199   * Current position of the user represented by
200   * {@link Point}
201   */
202  position: Point;
203  /**
204   * Current altitude of the user
205   */
206  altitude: number;
207  /**
208   * The radius of uncertainty for the user'slocation, measured in meters.
209   */
210  accuracy: number;
211  /**
212   * Accuracy of current altitude estimate
213   */
214  verticalAccuracy: number;
215  /**
216   * Current speed of the user measured im meters per second
217   */
218  speed: number;
219  /**
220   * Accuracy of the current speed estimate
221   */
222  speedAccuracy: number;
223  /**
224   * Direction the user is heading
225   */
226  heading: number;
227  /**
228   * The time at which this location was determined
229   */
230  timestamp: number;
231};
232
233export type Color =
234  | 'red'
235  | 'blue'
236  | 'green'
237  | 'black'
238  | 'white'
239  | 'gray'
240  | 'cyan'
241  | 'magenta'
242  | 'yellow'
243  | 'lightgray'
244  | 'darkgray'
245  | 'aqua'
246  | 'fuchsia'
247  | 'lime'
248  | 'maroon'
249  | 'navy'
250  | 'olive'
251  | 'purple'
252  | 'silver'
253  | 'teal';
254
255/**
256 * Possible power priorities for OnLocationChange event
257 */
258export enum LocationChangePriority {
259  /**
260   * Best accuracy that the device can acquire. Will consume more power.
261   */
262  PRIORITY_HIGH_ACCURACY = 100,
263  /**
264   * Bock level accuracy. Block level accuracy is considered to be about 100 meter accuracy.
265   */
266  PRIORITY_BALANCED_POWER_ACCURACY = 102,
267  /**
268   * City level accuracy. City level accuracy is considered to be about 10km accuracy.
269   * Using a coarse accuracy such as this often consumes less power
270   */
271  PRIORITY_LOW_POWER = 104,
272  /**
273   * No locations will be returned unless a different client has requested location updates in which case
274   * this request will act as a passive listener to those locations. Will use no additional power
275   */
276  PRIORITY_NO_POWER = 105,
277}
278