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: { COMMAND }
Object: { provider, latitude, longitude, speed, bearing, altitude, accuracy }
function( data, time )
loc.Batch
Batch method calls to be able to set all object's properties at once.
Note that you need to specify each parameter (use “” or null to leave some out)
Inherited methods can be called by appending an underscore to the function name (ie. txt.Batch({ SetBackColor_: [“red”] })
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.