[ReactNative] geolocation method docs

This commit is contained in:
Spencer Ahrens
2015-04-24 16:10:46 -07:00
parent a1a15bda06
commit 68eb3e4906
2 changed files with 18 additions and 3 deletions

View File

@@ -22,6 +22,12 @@ var subscriptions = [];
var updatesEnabled = false;
type GeoOptions = {
timeout: number;
maximumAge: number;
enableHighAccuracy: bool;
}
/**
* You need to include the `NSLocationWhenInUseUsageDescription` key
* in Info.plist to enable geolocation. Geolocation is enabled by default
@@ -32,10 +38,14 @@ var updatesEnabled = false;
*/
var Geolocation = {
/*
* Invokes the success callback once with the latest location info. Supported
* options: timeout (ms), maximumAge (ms), enableHighAccuracy (bool)
*/
getCurrentPosition: function(
geo_success: Function,
geo_error?: Function,
geo_options?: Object
geo_options?: GeoOptions
) {
invariant(
typeof geo_success === 'function',
@@ -48,7 +58,11 @@ var Geolocation = {
);
},
watchPosition: function(success: Function, error?: Function, options?: Object): number {
/*
* Invokes the success callback whenever the location changes. Supported
* options: timeout (ms), maximumAge (ms), enableHighAccuracy (bool)
*/
watchPosition: function(success: Function, error?: Function, options?: GeoOptions): number {
if (!updatesEnabled) {
RCTLocationObserver.startObserving(options || {});
updatesEnabled = true;