|
1 | | -/* |
| 1 | +/** |
| 2 | + * Copyright (c) Facebook, Inc. and its affiliates. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + * |
2 | 7 | * @format |
3 | 8 | * @flow |
4 | 9 | */ |
5 | 10 |
|
6 | | -type GeoOptions = { |
7 | | - timeout: number, |
8 | | - maximumAge: number, |
9 | | - enableHighAccuracy: boolean, |
10 | | -}; |
| 11 | +import Geolocation from './implementation'; |
11 | 12 |
|
12 | | -const Geolocation = { |
13 | | - setRNConfiguration: function() { |
14 | | - throw new Error('method not supported by the browser'); |
15 | | - }, |
16 | | - requestAuthorization: function() { |
17 | | - throw new Error('method not supported by the browser'); |
18 | | - }, |
19 | | - getCurrentPosition: async function( |
20 | | - success: Function, |
21 | | - error?: Function, |
22 | | - options?: GeoOptions, |
23 | | - ) { |
24 | | - if (typeof success !== 'function') { |
25 | | - throw new Error('success callback must be a function'); |
26 | | - } else if (!navigator || !navigator.geolocation) { |
27 | | - console.error('Navigator is undefined'); |
28 | | - return; |
29 | | - } |
30 | | - navigator.geolocation.getCurrentPosition(success, error, options); |
31 | | - }, |
32 | | - watchPosition: function( |
33 | | - success: Function, |
34 | | - error?: Function, |
35 | | - options?: GeoOptions, |
36 | | - ) { |
37 | | - if (typeof success !== 'function') { |
38 | | - throw new Error('success callback must be a function'); |
39 | | - } else if (!navigator || !navigator.geolocation) { |
40 | | - console.error('Navigator is undefined'); |
41 | | - return; |
42 | | - } |
43 | | - navigator.geolocation.watchPosition(success, error, options); |
44 | | - }, |
45 | | - clearWatch: function(watchID: number) { |
46 | | - if (!navigator || !navigator.geolocation) { |
47 | | - console.error('Navigator is undefined'); |
48 | | - return; |
49 | | - } |
50 | | - navigator.geolocation.clearWatch(watchID); |
51 | | - }, |
52 | | - stopObserving: function() { |
53 | | - throw new Error('method not supported by the browser'); |
54 | | - }, |
55 | | -}; |
56 | 13 | module.exports = Geolocation; |
0 commit comments