Positioning


Monkey C provides access to the wearable's available sensors, which may include the GPS, altimeter, thermometer, and supported ANT sensors.

APIPurposeAPI Level
Position.LocationAbstraction of a coordinate1.0.0
Position.enableLocationEvents()Allows enabling the GPS and receiving location update events to a callback.Requires the Position permission.1.0.0
Position.getInfo()Query the position information from the system1.0.0

Location

A Position.Location is an abstraction of a coordinate. It exposes the ability to retrieve the coordinates in radians or decimal degrees and then provides a method to convert to coordinate formats supported by the Garmin system. The Toybox.Position module also exposes string parsing interface to convert from various coordinate formats to a Position.Location object.

Location Events

To enable the GPS call the Position.enableLocationEvents() method. To register a position listener, use the Object.method() call to create a Lang.Method callback:

function onPosition( info as Position.Info ) as Void {
    Sys.println( "Position " + info.position.toGeoString( Position.GEO_DM ) );
}

function initializeListener() as Void {
    Position.enableLocationEvents( Position.LOCATION_CONTINUOUS, method( :onPosition ) );
}

All of the location information will be sent in an Position.Info object. You can also use Position.getInfo() to retrieve an Position.Info instance.

For more, see the PositionSample sample app distributed with the SDK.

Multi-Band

There are times where you may want control over what positioning solution is used. The :configuration option of Position.enableLocationEvents() allows you to specify the which positioning solution you wish to use:

ConfigurationGPS SolutionAPI Level
CONFIGURATION_GPSGPS L13.3.6
CONFIGURATION_GPS_GLONASSGPS L1, GLONASS3.3.6
CONFIGURATION_GPS_GALILEOGPS L1, GALILEO L13.3.6
CONFIGURATION_GPS_BEIDOUGPS L1, BEIDOU L13.3.6
CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1GPS L1, GLONASS, GALILEO L1, BEIDOU L13.3.6
CONFIGURATION_GPS_GLONASS_GALILEO_BEIDOU_L1_L5GPS L1, GLONASS, GALILEO L1, BEIDOU L1, GPS L5, GALILEO L5, BEIDOU L53.3.6
CONFIGURATION_SAT_IQSolution chosen dynamically for optimum power usage3.3.6

Not every device supports every GPS configuration. You can use Position.hasConfigurationSupport() to determine if the device supports a specific configuration.