Moscrif API Docs for: 2012q3
Show:

GPS Class

Library: sensor

GPS class manages all operations with gps hardware.

Item Index

Methods

Methods

this

()

Constructs new GPS object.

Example:

this._gps = new GPS();
this._gps.start(200);
this._gps.onPositionReceived = function(sender, timestamp, params) {
    app.actualLat = params[0];
    app.actualLon = params[1];
}

dispose

()

Destroy object and release all underlying resources.

isAvailable

()

Function returns true if GPS is available on the device. Otherwise it returns false.

Returns:

Boolean

Example:

if (!GPS.isAvailable())
    System.messageBox("No GPS detected in your device!");

pause

()

Pause sending callback data.

resume

()

Resume sending callback data.

start

()

This function starts sending position data. When new data are available, GPS object calls callback functions.

Example:

this._gps = new GPS();
this._gps.start(200);
this._gps.onPositionReceived = function(sender, timestamp, params) {
    app.actualLat = params[0];
    app.actualLon = params[1];
}

Events

onPositionReceived

GPS object call this callback function, when new position data is available.

Event Payload:

  • sender GPS

    Sender object.

  • timestamp Integer

    Time information.

  • params Array

    Array with 3 elements

    • params[0] - latitude
    • params[1] - longitude
    • params[2] - altitude

Example:

this._gps = new GPS();
this._gps.start(200);
this._gps.onPositionReceived = function(sender, timestamp, params) {
    app.actualLat = params[0];
    app.actualLon = params[1];
}

onStateChanged

GPS object call this callback function, when new state data is available.

Event Payload:

  • sender GPS

    Sender object.

  • timestamp Integer

    Time information.

  • params Array

    State information.

Example:

this._gps = new GPS();
this._gps.start(200);
this._gps.onStateChanged = function(sender, timestamp, state) {
    console<<"new state: "<<state<<"\n";
}