1- import promises = require( "promises" ) ;
1+
2+ declare module "location" {
3+ import promises = require( "promises" ) ;
4+
5+ enum Accuracy {
6+ // in meters
7+ ANY ,
8+ HIGH ,
9+ }
10+
11+ // For future usage
12+ //class LocationRegion {
13+ // public latitude: number;
14+ // public longitude: number;
15+
16+ // public raduis: number; // radius in meters
17+ //}
18+
19+ class Location {
20+ latitude : number ;
21+ longitude : number ;
22+
23+ altitude : number ; // in meters
24+
25+ horizontalAccuracy : number ; // in meters
26+ verticalAccuracy : number ; // in meters
27+
28+ speed : number ; // in m/s
29+
30+ direction : number ; // in degrees
31+
32+ timestamp : Date ;
33+
34+ public android : any ; // android Location
35+ public ios : any ; // iOS CLLocation
36+ }
37+
38+ export interface Options {
39+ /**
40+ * Specifies desired accuracy in meters. Defaults to DesiredAccuracy.HIGH
41+ */
42+ desiredAccuracy ?: number ;
43+
44+ /**
45+ * Update distance filter in meters. Specifies how often to update. Default on iOS is no filter, on Android it is 0 meters
46+ */
47+ updateDistance ?: number ;
48+
49+ /**
50+ * Minimum time interval between location updates, in milliseconds (ignored on iOS)
51+ */
52+ minimumUpdateTime ?: number ;
53+
54+ /**
55+ * how old locations to receive in ms.
56+ */
57+ maximumAge ?: number ;
58+
59+ /**
60+ * how long to wait for a location in ms.
61+ */
62+ timeout ?: number ;
63+ }
64+
65+ class LocationManager {
66+ /**
67+ * Report are location services switched ON for this device (on Android) or application (iOS)
68+ */
69+ static isEnabled ( ) : boolean ;
70+
71+ /**
72+ * Measure distance in meters between two locations
73+ */
74+ static distance ( loc1 : Location , loc2 : Location ) : number ;
75+
76+ /**
77+ * Specifies desired accuracy in meters. Defaults to DesiredAccuracy.HIGH
78+ */
79+ desiredAccuracy : number ;
80+
81+ /**
82+ * Update distance filter in meters. Specifies how often to update. Default on iOS is no filter, on Android it is 0 meters
83+ */
84+ updateDistance : number ;
85+
86+ /**
87+ * Minimum time interval between location updates, in milliseconds (ignored on iOS)
88+ */
89+ minimumUpdateTime : number ;
90+
91+ /**
92+ * True if location listener is already started. In this case all other start requests will be ignored
93+ */
94+ isStarted : boolean ;
95+
96+ // monitoring
97+
98+ /**
99+ * Starts location monitoring.
100+ */
101+ startLocationMonitoring ( onLocation : ( location : Location ) => any , onError ?: ( error : Error ) => any , options ?: Options ) ;
102+
103+ /**
104+ * Stops location monitoring
105+ */
106+ stopLocationMonitoring ( ) ;
107+
108+ // other
2109
3- export declare enum Accuracy {
4- // in meters
5- ANY ,
6- HIGH ,
7- }
8-
9- // For future usage
10- //export declare class LocationRegion {
11- // public latitude: number;
12- // public longitude: number;
13-
14- // public raduis: number; // radius in meters
15- //}
16-
17- export declare class Location {
18- latitude : number ;
19- longitude : number ;
20-
21- altitude : number ; // in meters
22-
23- horizontalAccuracy : number ; // in meters
24- verticalAccuracy : number ; // in meters
25-
26- speed : number ; // in m/s
27-
28- direction : number ; // in degrees
29-
30- timestamp : Date ;
31-
32- public android : any ; // android Location
33- public ios : any ; // iOS CLLocation
34- }
35-
36- export interface Options {
37- /**
38- * Specifies desired accuracy in meters. Defaults to DesiredAccuracy.HIGH
39- */
40- desiredAccuracy ?: number ;
41-
42- /**
43- * Update distance filter in meters. Specifies how often to update. Default on iOS is no filter, on Android it is 0 meters
44- */
45- updateDistance ?: number ;
46-
47- /**
48- * Minimum time interval between location updates, in milliseconds (ignored on iOS)
49- */
50- minimumUpdateTime ?: number ;
51-
52- /**
53- * how old locations to receive in ms.
54- */
55- maximumAge ?: number ;
56-
57- /**
58- * how long to wait for a location in ms.
59- */
60- timeout ?: number ;
61- }
62-
63- export declare class LocationManager {
64- /**
65- * Report are location services switched ON for this device (on Android) or application (iOS)
66- */
67- static isEnabled ( ) : boolean ;
68-
69- /**
70- * Measure distance in meters between two locations
71- */
72- static distance ( loc1 : Location , loc2 : Location ) : number ;
73-
74- /**
75- * Specifies desired accuracy in meters. Defaults to DesiredAccuracy.HIGH
76- */
77- desiredAccuracy : number ;
78-
79- /**
80- * Update distance filter in meters. Specifies how often to update. Default on iOS is no filter, on Android it is 0 meters
81- */
82- updateDistance : number ;
83-
84- /**
85- * Minimum time interval between location updates, in milliseconds (ignored on iOS)
86- */
87- minimumUpdateTime : number ;
88-
89- /**
90- * True if location listener is already started. In this case all other start requests will be ignored
91- */
92- isStarted : boolean ;
93-
94- // monitoring
95-
96- /**
97- * Starts location monitoring.
98- */
99- startLocationMonitoring ( onLocation : ( location : Location ) => any , onError ?: ( error : Error ) => any , options ?: Options ) ;
100-
101- /**
102- * Stops location monitoring
103- */
104- stopLocationMonitoring ( ) ;
105-
106- // other
110+ /**
111+ * Returns last known location from device's location services or null of no known last location
112+ */
113+ lastKnownLocation : Location ;
114+ }
107115
108116 /**
109- * Returns last known location from device's location services or null of no known last location
117+ * Fires a single shot location search. If you specify timeout in options, location search will fail on timeout.
118+ * If you specify timeout = 0 it just requests the last known location. However if you specify maximumAge and the
119+ * location received is older it won't be received
110120 */
111- lastKnownLocation : Location ;
112- }
113-
114- /**
115- * Fires a single shot location search. If you specify timeout in options, location search will fail on timeout.
116- * If you specify timeout = 0 it just requests the last known location. However if you specify maximumAge and the
117- * location received is older it won't be received
118- */
119- export declare var getLocation : ( options ?: Options ) => promises . Promise < Location > ;
121+ var getLocation : ( options ?: Options ) => promises . Promise < Location > ;
122+ }
0 commit comments