-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Geolocation.js
655 lines (644 loc) · 18.8 KB
/
Geolocation.js
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
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
import { default as Window } from './UI/Window';
export default class Geolocation {
constructor (object) {
if (object && object.apiName && object.apiName.endsWith('.Geolocation')) {
this._object = object;
} else {
this._object = undefined;
}
}
// constants
static get apiName () {
return Titanium.Geolocation.apiName;
}
static get ACCURACY_BEST () {
return Titanium.Geolocation.ACCURACY_BEST;
}
static get ACCURACY_BEST_FOR_NAVIGATION () {
return Titanium.Geolocation.ACCURACY_BEST_FOR_NAVIGATION;
}
static get ACCURACY_HUNDRED_METERS () {
return Titanium.Geolocation.ACCURACY_HUNDRED_METERS;
}
static get ACCURACY_KILOMETER () {
return Titanium.Geolocation.ACCURACY_KILOMETER;
}
static get ACCURACY_NEAREST_TEN_METERS () {
return Titanium.Geolocation.ACCURACY_NEAREST_TEN_METERS;
}
static get ACCURACY_THREE_KILOMETERS () {
return Titanium.Geolocation.ACCURACY_THREE_KILOMETERS;
}
static get ACCURACY_HIGH () {
return Titanium.Geolocation.ACCURACY_HIGH;
}
static get ACCURACY_LOW () {
return Titanium.Geolocation.ACCURACY_LOW;
}
static get ACTIVITYTYPE_AUTOMOTIVE_NAVIGATION () {
return Titanium.Geolocation.ACTIVITYTYPE_AUTOMOTIVE_NAVIGATION;
}
static get ACTIVITYTYPE_FITNESS () {
return Titanium.Geolocation.ACTIVITYTYPE_FITNESS;
}
static get ACTIVITYTYPE_OTHER () {
return Titanium.Geolocation.ACTIVITYTYPE_OTHER;
}
static get ACTIVITYTYPE_OTHER_NAVIGATION () {
return Titanium.Geolocation.ACTIVITYTYPE_OTHER_NAVIGATION;
}
static get AUTHORIZATION_ALWAYS () {
return Titanium.Geolocation.AUTHORIZATION_ALWAYS;
}
static get AUTHORIZATION_AUTHORIZED () {
return Titanium.Geolocation.AUTHORIZATION_AUTHORIZED;
}
static get AUTHORIZATION_DENIED () {
return Titanium.Geolocation.AUTHORIZATION_DENIED;
}
static get AUTHORIZATION_RESTRICTED () {
return Titanium.Geolocation.AUTHORIZATION_RESTRICTED;
}
static get AUTHORIZATION_UNKNOWN () {
return Titanium.Geolocation.AUTHORIZATION_UNKNOWN;
}
static get AUTHORIZATION_WHEN_IN_USE () {
return Titanium.Geolocation.AUTHORIZATION_WHEN_IN_USE;
}
static get ERROR_DENIED () {
return Titanium.Geolocation.ERROR_DENIED;
}
static get ERROR_HEADING_FAILURE () {
return Titanium.Geolocation.ERROR_HEADING_FAILURE;
}
static get ERROR_LOCATION_UNKNOWN () {
return Titanium.Geolocation.ERROR_LOCATION_UNKNOWN;
}
static get ERROR_NETWORK () {
return Titanium.Geolocation.ERROR_NETWORK;
}
static get ERROR_REGION_MONITORING_DELAYED () {
return Titanium.Geolocation.ERROR_REGION_MONITORING_DELAYED;
}
static get ERROR_REGION_MONITORING_DENIED () {
return Titanium.Geolocation.ERROR_REGION_MONITORING_DENIED;
}
static get ERROR_REGION_MONITORING_FAILURE () {
return Titanium.Geolocation.ERROR_REGION_MONITORING_FAILURE;
}
static get PROVIDER_GPS () {
return Titanium.Geolocation.PROVIDER_GPS;
}
static get PROVIDER_NETWORK () {
return Titanium.Geolocation.PROVIDER_NETWORK;
}
static get PROVIDER_PASSIVE () {
return Titanium.Geolocation.PROVIDER_PASSIVE;
}
static get hasCompass () {
return Titanium.Geolocation.hasCompass;
}
static get locationServicesEnabled () {
return Titanium.Geolocation.locationServicesEnabled;
}
static get lastGeolocation () {
return Titanium.Geolocation.lastGeolocation;
}
// properties
get apiName () {
return this._object.apiName;
}
get bubbleParent () {
return this._object.bubbleParent;
}
set bubbleParent (value) {
this._object.bubbleParent = value;
}
get lifecycleContainer () {
return new Window(this._object.lifecycleContainer);
}
set lifecycleContainer (value) {
this._object.lifecycleContainer = value;
}
get frequency () {
return this._object.frequency;
}
set frequency (value) {
this._object.frequency = value;
}
get preferredProvider () {
return this._object.preferredProvider;
}
set preferredProvider (value) {
this._object.preferredProvider = value;
}
get purpose () {
return this._object.purpose;
}
set purpose (value) {
this._object.purpose = value;
}
get showCalibration () {
return this._object.showCalibration;
}
set showCalibration (value) {
this._object.showCalibration = value;
}
get trackSignificantLocationChange () {
return this._object.trackSignificantLocationChange;
}
set trackSignificantLocationChange (value) {
this._object.trackSignificantLocationChange = value;
}
get allowsBackgroundLocationUpdates () {
return this._object.allowsBackgroundLocationUpdates;
}
set allowsBackgroundLocationUpdates (value) {
this._object.allowsBackgroundLocationUpdates = value;
}
get activityType () {
return this._object.activityType;
}
set activityType (value) {
this._object.activityType = value;
}
get pauseLocationUpdateAutomatically () {
return this._object.pauseLocationUpdateAutomatically;
}
set pauseLocationUpdateAutomatically (value) {
this._object.pauseLocationUpdateAutomatically = value;
}
get ACCURACY_BEST () {
return this._object.ACCURACY_BEST;
}
get ACCURACY_BEST_FOR_NAVIGATION () {
return this._object.ACCURACY_BEST_FOR_NAVIGATION;
}
get ACCURACY_HUNDRED_METERS () {
return this._object.ACCURACY_HUNDRED_METERS;
}
get ACCURACY_KILOMETER () {
return this._object.ACCURACY_KILOMETER;
}
get ACCURACY_NEAREST_TEN_METERS () {
return this._object.ACCURACY_NEAREST_TEN_METERS;
}
get ACCURACY_THREE_KILOMETERS () {
return this._object.ACCURACY_THREE_KILOMETERS;
}
get ACCURACY_HIGH () {
return this._object.ACCURACY_HIGH;
}
get ACCURACY_LOW () {
return this._object.ACCURACY_LOW;
}
get ACTIVITYTYPE_AUTOMOTIVE_NAVIGATION () {
return this._object.ACTIVITYTYPE_AUTOMOTIVE_NAVIGATION;
}
get ACTIVITYTYPE_FITNESS () {
return this._object.ACTIVITYTYPE_FITNESS;
}
get ACTIVITYTYPE_OTHER () {
return this._object.ACTIVITYTYPE_OTHER;
}
get ACTIVITYTYPE_OTHER_NAVIGATION () {
return this._object.ACTIVITYTYPE_OTHER_NAVIGATION;
}
get AUTHORIZATION_ALWAYS () {
return this._object.AUTHORIZATION_ALWAYS;
}
get AUTHORIZATION_AUTHORIZED () {
return this._object.AUTHORIZATION_AUTHORIZED;
}
get AUTHORIZATION_DENIED () {
return this._object.AUTHORIZATION_DENIED;
}
get AUTHORIZATION_RESTRICTED () {
return this._object.AUTHORIZATION_RESTRICTED;
}
get AUTHORIZATION_UNKNOWN () {
return this._object.AUTHORIZATION_UNKNOWN;
}
get AUTHORIZATION_WHEN_IN_USE () {
return this._object.AUTHORIZATION_WHEN_IN_USE;
}
get ERROR_DENIED () {
return this._object.ERROR_DENIED;
}
get ERROR_HEADING_FAILURE () {
return this._object.ERROR_HEADING_FAILURE;
}
get ERROR_LOCATION_UNKNOWN () {
return this._object.ERROR_LOCATION_UNKNOWN;
}
get ERROR_NETWORK () {
return this._object.ERROR_NETWORK;
}
get ERROR_REGION_MONITORING_DELAYED () {
return this._object.ERROR_REGION_MONITORING_DELAYED;
}
get ERROR_REGION_MONITORING_DENIED () {
return this._object.ERROR_REGION_MONITORING_DENIED;
}
get ERROR_REGION_MONITORING_FAILURE () {
return this._object.ERROR_REGION_MONITORING_FAILURE;
}
get PROVIDER_GPS () {
return this._object.PROVIDER_GPS;
}
get PROVIDER_NETWORK () {
return this._object.PROVIDER_NETWORK;
}
get PROVIDER_PASSIVE () {
return this._object.PROVIDER_PASSIVE;
}
get accuracy () {
return this._object.accuracy;
}
set accuracy (value) {
this._object.accuracy = value;
}
get distanceFilter () {
return this._object.distanceFilter;
}
set distanceFilter (value) {
this._object.distanceFilter = value;
}
get headingFilter () {
return this._object.headingFilter;
}
set headingFilter (value) {
this._object.headingFilter = value;
}
get hasCompass () {
return this._object.hasCompass;
}
get locationServicesAuthorization () {
return this._object.locationServicesAuthorization;
}
set locationServicesAuthorization (value) {
this._object.locationServicesAuthorization = value;
}
get locationServicesEnabled () {
return this._object.locationServicesEnabled;
}
get lastGeolocation () {
return this._object.lastGeolocation;
}
// static properties
static get bubbleParent () {
return Titanium.Geolocation.bubbleParent;
}
static set bubbleParent (value) {
Titanium.Geolocation.bubbleParent = value;
}
static get showCalibration () {
return Titanium.Geolocation.showCalibration;
}
static set showCalibration (value) {
Titanium.Geolocation.showCalibration = value;
}
static get activityType () {
return Titanium.Geolocation.activityType;
}
static set activityType (value) {
Titanium.Geolocation.activityType = value;
}
static get accuracy () {
return Titanium.Geolocation.accuracy;
}
static set accuracy (value) {
Titanium.Geolocation.accuracy = value;
}
static get distanceFilter () {
return Titanium.Geolocation.distanceFilter;
}
static set distanceFilter (value) {
Titanium.Geolocation.distanceFilter = value;
}
static get headingFilter () {
return Titanium.Geolocation.headingFilter;
}
static set headingFilter (value) {
Titanium.Geolocation.headingFilter = value;
}
// methods
addEventListener (name, callback) {
if (!callback) {
return new Promise(resolve => this._object.addEventListener(name, resolve));
}
return this._object.addEventListener(name, callback);
}
applyProperties (props) {
props = normalize(props);
return this._object.applyProperties(props);
}
fireEvent (name, event) {
event = normalize(event);
return this._object.fireEvent(name, event);
}
removeEventListener (name, callback) {
if (!callback) {
return new Promise(resolve => this._object.removeEventListener(name, resolve));
}
return this._object.removeEventListener(name, callback);
}
forwardGeocoder (address, callback) {
if (!callback) {
return new Promise(resolve => this._object.forwardGeocoder(address, resolve));
}
return this._object.forwardGeocoder(address, callback);
}
getCurrentHeading (callback) {
if (!callback) {
return new Promise(resolve => this._object.getCurrentHeading(resolve));
}
return this._object.getCurrentHeading(callback);
}
getCurrentPosition (callback) {
if (!callback) {
return new Promise(resolve => this._object.getCurrentPosition(resolve));
}
return this._object.getCurrentPosition(callback);
}
reverseGeocoder (latitude, longitude, callback) {
if (!callback) {
return new Promise(resolve => this._object.reverseGeocoder(latitude, longitude, resolve));
}
return this._object.reverseGeocoder(latitude, longitude, callback);
}
hasLocationPermissions (authorizationType) {
return this._object.hasLocationPermissions(authorizationType);
}
requestLocationPermissions (authorizationType, callback) {
if (!callback) {
return new Promise(resolve => this._object.requestLocationPermissions(authorizationType, resolve));
}
return this._object.requestLocationPermissions(authorizationType, callback);
}
getApiName () {
return this._object.getApiName();
}
getBubbleParent () {
return this._object.getBubbleParent();
}
setBubbleParent (bubbleParent) {
return this._object.setBubbleParent(bubbleParent);
}
getLifecycleContainer () {
return new Window(this._object.getLifecycleContainer());
}
setLifecycleContainer (lifecycleContainer) {
lifecycleContainer = normalize(lifecycleContainer);
return this._object.setLifecycleContainer(lifecycleContainer);
}
getFrequency () {
return this._object.getFrequency();
}
setFrequency (frequency) {
return this._object.setFrequency(frequency);
}
getPreferredProvider () {
return this._object.getPreferredProvider();
}
setPreferredProvider (preferredProvider) {
return this._object.setPreferredProvider(preferredProvider);
}
getPurpose () {
return this._object.getPurpose();
}
setPurpose (purpose) {
return this._object.setPurpose(purpose);
}
getShowCalibration () {
return this._object.getShowCalibration();
}
setShowCalibration (showCalibration) {
return this._object.setShowCalibration(showCalibration);
}
getTrackSignificantLocationChange () {
return this._object.getTrackSignificantLocationChange();
}
setTrackSignificantLocationChange (trackSignificantLocationChange) {
return this._object.setTrackSignificantLocationChange(trackSignificantLocationChange);
}
getAllowsBackgroundLocationUpdates () {
return this._object.getAllowsBackgroundLocationUpdates();
}
setAllowsBackgroundLocationUpdates (allowsBackgroundLocationUpdates) {
return this._object.setAllowsBackgroundLocationUpdates(allowsBackgroundLocationUpdates);
}
getActivityType () {
return this._object.getActivityType();
}
setActivityType (activityType) {
return this._object.setActivityType(activityType);
}
getPauseLocationUpdateAutomatically () {
return this._object.getPauseLocationUpdateAutomatically();
}
setPauseLocationUpdateAutomatically (pauseLocationUpdateAutomatically) {
return this._object.setPauseLocationUpdateAutomatically(pauseLocationUpdateAutomatically);
}
getAccuracy () {
return this._object.getAccuracy();
}
setAccuracy (accuracy) {
return this._object.setAccuracy(accuracy);
}
getDistanceFilter () {
return this._object.getDistanceFilter();
}
setDistanceFilter (distanceFilter) {
return this._object.setDistanceFilter(distanceFilter);
}
getHeadingFilter () {
return this._object.getHeadingFilter();
}
setHeadingFilter (headingFilter) {
return this._object.setHeadingFilter(headingFilter);
}
getHasCompass () {
return this._object.getHasCompass();
}
getLocationServicesAuthorization () {
return this._object.getLocationServicesAuthorization();
}
setLocationServicesAuthorization (locationServicesAuthorization) {
return this._object.setLocationServicesAuthorization(locationServicesAuthorization);
}
getLocationServicesEnabled () {
return this._object.getLocationServicesEnabled();
}
getLastGeolocation () {
return this._object.getLastGeolocation();
}
// static methods
static addEventListener (name, callback) {
if (!callback) {
return new Promise(resolve => this._object.addEventListener(name, resolve));
}
return this._object.addEventListener(name, callback);
}
static applyProperties (props) {
props = normalize(props);
return this._object.applyProperties(props);
}
static fireEvent (name, event) {
event = normalize(event);
return this._object.fireEvent(name, event);
}
static removeEventListener (name, callback) {
if (!callback) {
return new Promise(resolve => this._object.removeEventListener(name, resolve));
}
return this._object.removeEventListener(name, callback);
}
static forwardGeocoder (address, callback) {
if (!callback) {
return new Promise(resolve => this._object.forwardGeocoder(address, resolve));
}
return this._object.forwardGeocoder(address, callback);
}
static getCurrentHeading (callback) {
if (!callback) {
return new Promise(resolve => this._object.getCurrentHeading(resolve));
}
return this._object.getCurrentHeading(callback);
}
static getCurrentPosition (callback) {
if (!callback) {
return new Promise(resolve => this._object.getCurrentPosition(resolve));
}
return this._object.getCurrentPosition(callback);
}
static reverseGeocoder (latitude, longitude, callback) {
if (!callback) {
return new Promise(resolve => this._object.reverseGeocoder(latitude, longitude, resolve));
}
return this._object.reverseGeocoder(latitude, longitude, callback);
}
static hasLocationPermissions (authorizationType) {
return this._object.hasLocationPermissions(authorizationType);
}
static requestLocationPermissions (authorizationType, callback) {
if (!callback) {
return new Promise(resolve => this._object.requestLocationPermissions(authorizationType, resolve));
}
return this._object.requestLocationPermissions(authorizationType, callback);
}
static getApiName () {
return this._object.getApiName();
}
static getBubbleParent () {
return this._object.getBubbleParent();
}
static setBubbleParent (bubbleParent) {
return this._object.setBubbleParent(bubbleParent);
}
static getLifecycleContainer () {
return new Window(this._object.getLifecycleContainer());
}
static setLifecycleContainer (lifecycleContainer) {
lifecycleContainer = normalize(lifecycleContainer);
return this._object.setLifecycleContainer(lifecycleContainer);
}
static getFrequency () {
return this._object.getFrequency();
}
static setFrequency (frequency) {
return this._object.setFrequency(frequency);
}
static getPreferredProvider () {
return this._object.getPreferredProvider();
}
static setPreferredProvider (preferredProvider) {
return this._object.setPreferredProvider(preferredProvider);
}
static getPurpose () {
return this._object.getPurpose();
}
static setPurpose (purpose) {
return this._object.setPurpose(purpose);
}
static getShowCalibration () {
return this._object.getShowCalibration();
}
static setShowCalibration (showCalibration) {
return this._object.setShowCalibration(showCalibration);
}
static getTrackSignificantLocationChange () {
return this._object.getTrackSignificantLocationChange();
}
static setTrackSignificantLocationChange (trackSignificantLocationChange) {
return this._object.setTrackSignificantLocationChange(trackSignificantLocationChange);
}
static getAllowsBackgroundLocationUpdates () {
return this._object.getAllowsBackgroundLocationUpdates();
}
static setAllowsBackgroundLocationUpdates (allowsBackgroundLocationUpdates) {
return this._object.setAllowsBackgroundLocationUpdates(allowsBackgroundLocationUpdates);
}
static getActivityType () {
return this._object.getActivityType();
}
static setActivityType (activityType) {
return this._object.setActivityType(activityType);
}
static getPauseLocationUpdateAutomatically () {
return this._object.getPauseLocationUpdateAutomatically();
}
static setPauseLocationUpdateAutomatically (pauseLocationUpdateAutomatically) {
return this._object.setPauseLocationUpdateAutomatically(pauseLocationUpdateAutomatically);
}
static getAccuracy () {
return this._object.getAccuracy();
}
static setAccuracy (accuracy) {
return this._object.setAccuracy(accuracy);
}
static getDistanceFilter () {
return this._object.getDistanceFilter();
}
static setDistanceFilter (distanceFilter) {
return this._object.setDistanceFilter(distanceFilter);
}
static getHeadingFilter () {
return this._object.getHeadingFilter();
}
static setHeadingFilter (headingFilter) {
return this._object.setHeadingFilter(headingFilter);
}
static getHasCompass () {
return this._object.getHasCompass();
}
static getLocationServicesAuthorization () {
return this._object.getLocationServicesAuthorization();
}
static setLocationServicesAuthorization (locationServicesAuthorization) {
return this._object.setLocationServicesAuthorization(locationServicesAuthorization);
}
static getLocationServicesEnabled () {
return this._object.getLocationServicesEnabled();
}
static getLastGeolocation () {
return this._object.getLastGeolocation();
}
// modules
};
Object.freeze(Geolocation);
function normalize (object) {
if (typeof object === 'object') {
if (object._object) {
return object._object;
}
for (let key in object) {
if (typeof object[key] === 'object') {
if (object[key]._object) {
object[key] = object[key]._object;
}
}
}
}
return object;
}