This namespace provides access to device geographic location management.
- Since:
Classes
Members
-
static, readonly LocationStatusCode :object
-
This enumeration represents an error status code of mobicontrol.location.LocationError.
Properties:
Name Type Description NO_PERMISSIONobject The agent has none of the necessary location permissions; both ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION are missing. LOCATION_SERVICES_OFFobject Location services are turned off. NOT_SUPPORTEDobject Location feature is not supported. UNKNOWNobject The exact error could not be determined. - Since:
Methods
-
static createGeofence(nodes) → {mobicontrol.location.Geofence}
-
Create a geofence. See also Location tutorial.
Parameters:
Name Type Description nodesArray.<mobicontrol.location.Location> The list of nodes forming the geofence. Returns:
mobicontrol.location.Geofence - A geofence formed by the given nodes.- Since:
-
static createLocation(latitude, longitude) → {mobicontrol.location.Location}
-
Create a location.
Parameters:
Name Type Description latitudenumber The latitude, must be between -90 and 90. longitudenumber The longitude, must be between -180 and 180. Returns:
mobicontrol.location.Location - A new location with the specified coordinates.- Since:
Example
const LATITUDE = 43.613562; const LONGITUDE = -79.752868; var destination = mobicontrol.location.createLocation(LATITUDE, LONGITUDE); navigate(destination) function navigate(place) { mobicontrol.log.info('Navigating to the destination - Latitude: ' + place.latitude + ',' + 'Longitude: ' + place.longitude); var intent = mobicontrol.android.createIntent() .withAction("android.intent.action.VIEW") .withData("google.navigation:q=" + place.latitude + "," + place.longitude); mobicontrol.android.startActivity(intent); } -
async, static locate(callbackFunction, invocationTimeoutInMillisopt)
-
Locate the device. See also Location tutorial.
Parameters:
Name Type Attributes Default Description callbackFunctionmobicontrol.location.locateCallback JavaScript function which is called when the device location attempt completes. invocationTimeoutInMillisnumber <optional>
120000 Invocation timeout in milliseconds. If the callback function isn't invoked before the timeout expires, it will be called with the timed-out result. - Since:
Example
mobicontrol.location.locate(onLocationEvent); function onLocationEvent(result) { if (result.isSuccessful) { var location = result.location; mobicontrol.log.info( "Latitude: " + location.latitude + ", " + "Longitude: " + location.longitude ); } }
Type Definitions
-
locateCallback(result)
-
Callback function for mobicontrol.location.locate.
Parameters:
Name Type Description resultobject Result of the device location attempt. Properties
Name Type Description locationmobicontrol.location.Location The current device location or nullif the device could not be located.errormobicontrol.location.LocationError Detailed error conditions in case of failure. This value is nullwhen the callback is successful or when there is a timeout.isSuccessfulboolean Success status of the callback. trueif the callback completed successfully,falseotherwise.isTimedOutboolean Timeout status of the callback. trueif the callback was timed out,falseotherwise. Note: A timeout is considered a failure, so if the timeout status istrue, failure status istrueas well, and success status isfalse.isFailedboolean Failure status of the callback. trueif the callback failed,falseotherwise.- Since: