forked from NativeScript/NativeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocation.d.ts
More file actions
160 lines (134 loc) · 4.61 KB
/
location.d.ts
File metadata and controls
160 lines (134 loc) · 4.61 KB
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
/**
* Allows you to use the geolocation of the device.
*/
declare module "location" {
// For future usage
//class LocationRegion {
// public latitude: number;
// public longitude: number;
// public raduis: number; // radius in meters
//}
/**
* A data class that encapsulates common properties for a geolocation.
*/
export class Location {
/**
* The latitude of the geolocation, in degrees.
*/
latitude: number;
/**
* The longitude of the geolocation, in degrees.
*/
longitude: number;
/**
* The altitude (if available), in meters above sea level.
*/
altitude: number;
/**
* The horizontal accuracy, in meters.
*/
horizontalAccuracy: number;
/**
* The vertical accuracy, in meters.
*/
verticalAccuracy: number;
/**
* The speed, in meters/second over ground.
*/
speed: number;
/**
* The direction (course), in degrees.
*/
direction: number;
/**
* The time at which this location was determined.
*/
timestamp: Date;
/**
* The android-specific [location](http://developer.android.com/reference/android/location/Location.html) object.
*/
android: android.location.Location;
/**
* The ios-specific [CLLocation](https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/) object.
*/
ios: CLLocation;
}
/**
* Provides options for location monitoring.
*/
export interface Options {
/**
* Specifies desired accuracy in meters. Defaults to DesiredAccuracy.HIGH
*/
desiredAccuracy?: number;
/**
* Update distance filter in meters. Specifies how often to update. Default on iOS is no filter, on Android it is 0 meters
*/
updateDistance?: number;
/**
* Minimum time interval between location updates, in milliseconds (ignored on iOS)
*/
minimumUpdateTime?: number;
/**
* how old locations to receive in ms.
*/
maximumAge?: number;
/**
* how long to wait for a location in ms.
*/
timeout?: number;
}
/**
* Provides methods for querying geolocation (in case available) on the target platform.
*/
export class LocationManager {
/**
* Checks whether the location services are switched ON for this device (on Android) or application (iOS).
*/
static isEnabled(): boolean;
/**
* Measures the distance in meters between two locations.
* @param loc1 The first location.
* @param loc2 The second location.
*/
static distance(loc1: Location, loc2: Location): number;
/**
* The desired accuracy in meters. Defaults to DesiredAccuracy.HIGH
*/
desiredAccuracy: number;
/**
* The update distance filter in meters. Specifies how often to update. Default on iOS is no filter, on Android it is 0 meters.
*/
updateDistance: number;
/**
* The minimum time interval between subsequent location updates, in milliseconds (ignored on iOS).
*/
minimumUpdateTime: number;
/**
* True if the location listener is already started. In this case all other start requests will be ignored.
*/
isStarted: boolean;
/**
* Starts location monitoring.
* @param onLocation A function that will be called upon every location update received.
* @param onError An optional error callback.
* @param options An optional object specifying location update settings.
*/
startLocationMonitoring(onLocation: (location: Location) => any, onError?: (error: Error) => any, options?: Options);
/**
* Stops location monitoring.
*/
stopLocationMonitoring();
/**
* Returns last known location from device's location services or null of no known last location.
*/
lastKnownLocation: Location;
}
/**
* Fires a single shot location search. If you specify timeout in options, location search will fail on timeout.
* If you specify timeout = 0 it just requests the last known location.
* However if you specify maximumAge and the location received is older it won't be received.
* @param options An optional object specifying location update settings.
*/
export function getLocation(options?: Options): Promise<Location>;
}