Back

CreateLocator

Hello World
Content:
- Methods

The Locator component can be used to find your whereabouts on the planet using either your device's GPS or information from your network.

loc = app.CreateLocator( type, options ) → app object: Locator

The provider specifies where the locator should retreive its information from . “Network” means get the location from the cell network and wifi, “GPS” tells the locator to use the device's GPS

To Start the locator use the Start method. You can also stop it with Stop.
To get regulat updates about your current positino use the SetOnChange function.

Example - Get Location Updates

function OnStart()
{
    loc = app.CreateLocator("GPS,Network");
    loc.SetOnChange(loc_OnChange);
    loc.Start();
    app.ShowPopup("Locating");

}

function loc_OnChange(pos)
{
    var msg = pos.latitude + ", " + pos.longitude;
    app.ShowPopup( msg );
}
    Copy     Copy All       Run      

Methods

The following methods are available on the Locator object:

GetType() → string: “Locator”
Start()
Stop()
number
number: seconds
string: comma “,” separated
string: comma “,” separated: “GPS”, “Network”
object: { provider, latitude, longitude, speed, bearing, altitude, accuracy }
function( data, time )
loc.GetBearingTo
Returns the approximate initial bearing in degrees East of true North when traveling along the shortest path between this location and the given location.
loc.GetDistanceTo
Returns the approximate distance in meters between this location and the given location.
loc.GetType
Returns the control class name.
loc.SetOnChange
Define a function which is called when some of the values changed.
loc.SetRate
Set Locator update frequency in seconds
loc.Start
Start the locator.
loc.Stop
Stop the locator.