# Namespace: Location

## CB_Device. Location

Static class to manage the device's location. It will return itself if it is tried to be instantiated.

Source:
  - CrossBase/device/CB_Device.js, line 96
To Do:
  - Normalize more differences between web clients.

### Members

#### <static, readonly> getConstantly_callbackError :function|null

  Keeps the callback function used when there is an error getting the location for the `CB_Device.Location.getConstantly` function.

  ##### Type:

  - function | null
  Source:
    - CrossBase/device/CB_Device.js, line 165

#### <static, readonly> getConstantly_callbackOk :function|null

  Keeps the callback function used when location can be gotten successfully for the `CB_Device.Location.getConstantly` function.

  ##### Type:

  - function | null
  Source:
    - CrossBase/device/CB_Device.js, line 155

#### <static, readonly> getConstantly_lastId :integer|null

  Keeps the last watch ID that gets the location constantly. Used by the `CB_Device.Location.getConstantly` function.

  ##### Type:

  - integer | null
  Source:
    - CrossBase/device/CB_Device.js, line 105

#### <static, readonly> getConstantly_options :Object|undefined

  Keeps the last options used by the `CB_Device.Location.getConstantly` function.

  ##### Type:

  - Object | undefined
  Source:
    - CrossBase/device/CB_Device.js, line 175

#### <static, readonly> get_callbackError :function|null

  Keeps the callback function used when there is an error getting the location for the `CB_Device.Location.get` function.

  ##### Type:

  - function | null
  Source:
    - CrossBase/device/CB_Device.js, line 135

#### <static, readonly> get_callbackOk :function|null

  Keeps the callback function used when location can be gotten successfully for the `CB_Device.Location.get` function.

  ##### Type:

  - function | null
  Source:
    - CrossBase/device/CB_Device.js, line 125

#### <static, readonly> get_options :Object|undefined

  Keeps the last options used by the `CB_Device.Location.get` function.

  ##### Type:

  - Object | undefined
  Source:
    - CrossBase/device/CB_Device.js, line 145

#### <static, readonly> keepAwake_locationLockGPS :Object|null

  Keeps the "WakeLock" (MozWakeLock) object to be able to release the lock related with the GPS (so far, only works in Firefox/Firefox OS). Used by the `CB_Device.Location.keepAwake` function.

  ##### Type:

  - Object | null
  Source:
    - CrossBase/device/CB_Device.js, line 115

### Methods

#### <static> get( [callbackOk] [, callbackError] [, options] [, keepOldCallbackOk] [, keepOldCallbackError] [, keepOldOptions]) → {undefined|false}

  Gets the current position. Uses the Geolocation API (or compatible one as Apache Cordova's Geolocation plugin).

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `callbackOk` | function | <optional> |  | Callback that will be called if it gets the location successfully. Following the same rules as the first parameter of the native getCurrentPosition function.
  `callbackError` | function | <optional> |  | Callback that will be called if there is any error getting the location. Following the same rules as the second parameter of the native getCurrentPosition function.
  `options` | Object | <optional> |  | Object that represents the desired options. This parameter will be ignored if "keepOldOptions" is set to true. Following the same rules as the third parameter of the native getCurrentPosition function.
  `keepOldCallbackOk` | boolean | <optional> | true | If it is set to false, it will not keep the old previous "callbackOk" (if any) which was/were set in previous calls to this function.
  `keepOldCallbackError` | boolean | <optional> | true | If it is set to false, it will not keep the old previous "callbackError" (if any) which was/were set in previous calls to this function.
  `keepOldOptions` | boolean | <optional> | false | If it is set to true, it will ignore the given options and it will try to use the old previous options (if any) which were set in previous calls to this function.

  Source:
    - CrossBase/device/CB_Device.js, line 201

  ##### Returns:

  Returns false in the case that Geolocation API (or compatible one as Apache Cordova's Geolocation plugin) is not supported or undefined otherwise.

  Type
    undefined | false

#### <static> getConstantly( [callbackOkOrId] [, callbackError] [, options] [, keepOldCallbackOk] [, keepOldCallbackError] [, keepOldOptions]) → {integer|undefined|false}

  Starts or stops getting the current position constantly (real-time) every time it changes. Uses the Geolocation API (or compatible one as Apache Cordova's Geolocation plugin).

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `callbackOkOrId` | function | integer | <optional> | `CB_Device.Location.getConstantly_lastId` | In the case that we want to start getting the position, use a function callback that will be called every time it gets the location successfully (using the native watchPosition function). To stop getting the position, use the watch ID that we want to stop (using the native clearWatch function). Following the same rules as the first parameter of the native watchPosition function (when we want to start watching) or the first parameter of clearWatch function (when we want to stop watching).
  `callbackError` | function | <optional> |  | Callback that will be called if there is any error getting the location. Only used when we want to start getting the current position ("callbackOkOrId" is a function). Following the same rules as the second parameter of the native watchPosition function.
  `options` | Object | <optional> |  | Object that represents the desired options. This parameter will be ignored if "keepOldOptions" is set to true. Only used when we want to start getting the current position ("callbackOkOrId" is a function). Following the same rules as the third parameter of the native watchPosition function.
  `keepOldCallbackOk` | boolean | <optional> | true | If it is set to false, it will not keep the old previous "callbackOk" (if any) which was/were set in previous calls to this function. Only used when we want to start getting the current position ("callbackOkOrId" is a function).
  `keepOldCallbackError` | boolean | <optional> | true | If it is set to false, it will not keep the old previous "callbackError" (if any) which was/were set in previous calls to this function. Only used when we want to start getting the current position ("callbackOkOrId" is a function).
  `keepOldOptions` | boolean | <optional> | false | If it is set to true, it will ignore the given options and it will try to use the old previous options (if any) which were set in previous calls to this function. Only used when we want to start getting the current position ("callbackOkOrId" is a function).

  Source:
    - CrossBase/device/CB_Device.js, line 265

  ##### Returns:

  Returns false in the case that Geolocation API (or compatible one as Apache Cordova's Geolocation plugin) is not supported. In the case that we want to start getting the current position ("callbackOkOrId" is a function), it will return the watch ID that has been created. In the case that we want to stop getting the position ("callbackOkOrId" is a watch ID), it will return undefined.

  Type
    integer | undefined | false

#### <static> getConstantlyDisable( [id] [, keepOldCallbackOk] [, keepOldCallbackError] [, keepOldOptions]) → {undefined|false}

  Stops getting the current position constantly (real-time) every time it changes. Uses the Geolocation API (or compatible one as Apache Cordova's Geolocation plugin).

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `id` | integer | <optional> | `CB_Device.Location.getConstantly_lastId` | The watch ID that we want to stop. Following the same rules as the first parameter of the native clearWatch function.
  `keepOldCallbackOk` | boolean | <optional> | false | If it is set to false, it will not remove the current "callbackOk" (if any) which was/were set previously.
  `keepOldCallbackError` | boolean | <optional> | false | If it is set to false, it will remove the current "callbackError" (if any) which was/were set previously.
  `keepOldOptions` | boolean | <optional> | false | If it is set to false, it will remove the current "options" (if any) which were set previously.

  Source:
    - CrossBase/device/CB_Device.js, line 342

  ##### Returns:

  Returns false in the case that Geolocation API (or compatible one as Apache Cordova's Geolocation plugin) is not supported or undefined otherwise.

  Type
    undefined | false

#### <static> isSupported() → {boolean}

  Tells whether the Geolocation API (or compatible one as Apache Cordova's Geolocation plugin) is supported or not.

  Source:
    - CrossBase/device/CB_Device.js, line 183

  ##### Returns:

  Type
    boolean

#### <static> keepAwake( [keepAwake] [, lock]) → {undefined|Object|false}

  Keeps or stops keeping the application getting the position, even when the application is invisible or screen is locked, by using requestWakeLock (so far, only works in Firefox/Firefox OS).

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `keepAwake` | boolean | <optional> | true | Defines whether we want to keep it awake or stop doing it.
  `lock` | Object | <optional> | `CB_Device.Location.keepAwake_locationLockGPS` | The "WakeLock" (MozWakeLock) object that we want to unlock. It will be used only when "keepAwake" is set to false.

  Source:
    - CrossBase/device/CB_Device.js, line 360

  ##### Returns:

  Returns false in the case that "WakeLock" (MozWakeLock) is not supported or something went wrong. Returns the "WakeLock" (MozWakeLock) object in the case that we wanted to keep it awake ("keepAwake" is set to true). Returns undefined in the case that we do not want it to keep it awake ("keepAwake" is set to false and the lock is a valid "WakeLock" object).

  Type
    undefined | Object | false

#### Search results