|
| 1 | +type coords = { |
| 2 | + . |
| 3 | + "speed": float, |
| 4 | + "longitude": float, |
| 5 | + "latitude": float, |
| 6 | + "accuracy": float, |
| 7 | + "heading": float, |
| 8 | +}; |
| 9 | + |
| 10 | +type position = { |
| 11 | + . |
| 12 | + "coords": coords, |
| 13 | + "timestamp": float, |
| 14 | +}; |
| 15 | + |
| 16 | +type error = { |
| 17 | + . |
| 18 | + "code": int, |
| 19 | + "message": string, |
| 20 | +}; |
| 21 | + |
| 22 | +type config; |
| 23 | +[@bs.obj] |
| 24 | +external config: (~skipPermissionRequests: bool=?, unit) => config = ""; |
| 25 | + |
| 26 | +[@bs.val] [@bs.scope ("navigator", "geolocation")] |
| 27 | +external setRNConfiguration: config => unit = ""; |
| 28 | + |
| 29 | +[@bs.val] [@bs.scope ("navigator", "geolocation")] |
| 30 | +external requestAuthorization: unit => unit = ""; |
| 31 | + |
| 32 | +[@bs.val] [@bs.scope ("navigator", "geolocation")] |
| 33 | +external stopObserving: unit => unit = ""; |
| 34 | + |
| 35 | +type currentPositionOptions; |
| 36 | +[@bs.obj] |
| 37 | +external currentPositionOptions: |
| 38 | + ( |
| 39 | + ~timeout: float=?, |
| 40 | + ~maximumAge: float=?, |
| 41 | + ~enableHighAccuracy: bool=?, |
| 42 | + unit |
| 43 | + ) => |
| 44 | + currentPositionOptions = |
| 45 | + ""; |
| 46 | + |
| 47 | +[@bs.val] [@bs.scope ("navigator", "geolocation")] |
| 48 | +external getCurrentPosition: |
| 49 | + ( |
| 50 | + position => unit, |
| 51 | + ~onError: error => unit=?, |
| 52 | + ~options: currentPositionOptions=?, |
| 53 | + unit |
| 54 | + ) => |
| 55 | + unit = |
| 56 | + ""; |
| 57 | + |
| 58 | +type watchId; |
| 59 | + |
| 60 | +type watchPositionOptions; |
| 61 | +[@bs.obj] |
| 62 | +external watchPositionOptions: |
| 63 | + ( |
| 64 | + ~timeout: float=?, |
| 65 | + ~maximumAge: float=?, |
| 66 | + ~enableHighAccuracy: bool=?, |
| 67 | + ~distanceFilter: float=?, |
| 68 | + ~useSignificantChanges: bool=?, |
| 69 | + unit |
| 70 | + ) => |
| 71 | + watchPositionOptions = |
| 72 | + ""; |
| 73 | + |
| 74 | +[@bs.val] [@bs.scope ("navigator", "geolocation")] |
| 75 | +external watchPosition: |
| 76 | + ( |
| 77 | + position => unit, |
| 78 | + ~onError: error => unit=?, |
| 79 | + ~options: watchPositionOptions=?, |
| 80 | + unit |
| 81 | + ) => |
| 82 | + watchId = |
| 83 | + ""; |
| 84 | + |
| 85 | +[@bs.val] [@bs.scope ("navigator", "geolocation")] |
| 86 | +external clearWatch: watchId => unit = ""; |
0 commit comments