getLocation

GeoLocation

Returns the current location of the device.

$m.getLocation(function(response){

if(response.code){

var coords = response.result.position.coords;

$m.alert("Your location-" + coords.latitude + "-" + coords.longitude);

        } else{

                $m.alert(response.error.message);

        }

);

Syntax

        $m.getLocation(fp_callback)

        $m.getLocation(options, fp_callback)

Parameters

options

object (optional)

Optional parameters for the getLocation operation. It can contain one or more of the following properties,

  1. enableHighAccuracy - {Boolean}. True, if the location needs to be accurate. Setting true would activate gps receiver and hence the battery consumption will be higher. Default value is false.

  1. timeout - {Number}. Timeout for receiving location information in seconds. If the location is not received within the specified time, the location tracking is cancelled and a timeout error is thrown.

fp_callback

function (required)

Function to execute after the location information is obtained. The function receives a response object as parameter, with the following properties,

  1. code - {Integer}. 0 if the location providers are not enabled or any other errors. 1, otherwise.

  1. result - {Object}. Object containing the following properties,
  1. coords - {Object}. Location information containing properties,
  1. latitude - {Number}.
  2. longitude - {Number}.
  3. altitude - {Number}.
  4. horizontalAccuracy - {Number}.
  5. verticalAccuracy - {Number}.
  6. speed - {Number}.
  7. heading - {Number}.
  1. timestamp - {Number}. Time when the location information is read.

  1. error - {Object}. The error object contains,
  1. message - {String}. A short description of the error.
  2. description - {String}. A detailed description of the error.