-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
36 lines (32 loc) · 923 Bytes
/
index.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
'use strict';
var ReactNative = require('react-native');
var {
NativeModules,
DeviceEventEmitter
} = ReactNative;
const RNGeolocation = NativeModules.RNGeolocation;
const onLocationChanged = 'onLocationChangedEvent';
module.exports = {
startLocation: function (options) {
RNGeolocation.startLocation(options);
},
stopLocation: function () {
RNGeolocation.stopLocation();
},
destroyLocation: function () {
RNGeolocation.destroyLocation();
},
addEventListener: function (handler) {
const listener = DeviceEventEmitter.addListener(
onLocationChanged,
handler
);
return listener;
},
getLocation: function (options) {
return RNGeolocation.getLocation(options).then(data => data);
},
getAddress: function (options) {
return RNGeolocation.getAddress(options).then(data => data);
}
};