Location
The Location API provides access to the device’s geographic location, geocoding services, system map location picking, and heading (compass) information. It is available as a global API in Scripting and can be used directly without importing any modules.
The API respects system permissions, user-selected accuracy levels, and platform limitations, and is suitable for scripts, interactive views, and supported widget scenarios.
LocationAccuracy
Defines the desired accuracy level for location data.
Type Definition
Description
-
bestRequests the highest accuracy available on the device. -
tenMetersRequests approximately 10-meter accuracy. -
hundredMetersRequests approximately 100-meter accuracy. -
kilometerRequests approximately 1-kilometer accuracy. -
threeKilometersRequests coarse accuracy within approximately 3 kilometers. -
bestForNavigationOptimized for navigation use cases, with higher update frequency and power consumption. -
reducedRequests reduced-accuracy location data, typically used when the user has granted approximate location access.
LocationInfo
Represents a geographic coordinate with an associated timestamp.
Type Definition
Properties
-
latitudeLatitude in degrees. -
longitudeLongitude in degrees. -
timestampTime when the location was recorded, in milliseconds since the Unix epoch.
LocationPlacemark
Provides a human-readable description of a geographic location, usually returned by geocoding operations.
Type Definition
Description
A placemark may include address components, administrative regions, country information, and points of interest. Field availability depends on the location and system map data.
Heading
Represents compass and orientation information derived from the device’s sensors.
Type Definition
Properties
-
headingAccuracyMaximum deviation, in degrees, between the reported heading and the true geomagnetic heading. -
trueHeadingHeading relative to true north, in degrees. -
magneticHeadingHeading relative to magnetic north, in degrees. -
timestampTime at which the heading was measured. -
x,y,zRaw geomagnetic field values for the three axes, measured in microteslas.
Authorization and Configuration
isAuthorizedForWidgetUpdates
Indicates whether the current widget is eligible to receive location updates.
accuracy
The currently configured desired location accuracy.
setAccuracy
Sets the desired accuracy level for subsequent location requests. Higher accuracy may increase power consumption and require additional permissions.
Example
Requesting Location
requestCurrent
Requests the device’s current location.
By default, a cached location is returned immediately if available. If no cached location exists, a new location request is performed.
When forceRequest is set to true, any cached location is ignored and a fresh request is always made.
Example
Forcing a fresh location request:
pickFromMap
Presents the system map interface and allows the user to manually select a location.
Example
Geocoding
reverseGeocode
Converts a geographic coordinate into human-readable address information.
Example
geocodeAddress
Converts a textual address into geographic placemark results.
Example
Heading and Compass
requestHeading
Returns the most recently reported heading. If heading updates have never been started, the result is null.
Example
startUpdatingHeading
Starts continuous heading updates.
stopUpdatingHeading
Stops heading updates and releases related system resources.
addHeadingListener
Registers a listener that is called whenever the heading changes.
Example
removeHeadingListener
Removes a previously registered heading listener. If no listener is provided, all heading listeners are removed.
