LocationSensor
Last Updated On 2021-07-16
Version 3MinSDK 7Tutorial Video
Non-visible component providing location information, including longitude, latitude, altitude (if supported by the device), speed (if supported by the device), and address. This can also perform "geocoding", converting a given address (not necessarily the current one) to a latitude (with the LatitudeFromAddress
method) and a longitude (with the LongitudeFromAddress
method).
In order to function, the component must have its Enabled
property set to True, and the device must have location sensing enabled through wireless networks or GPS satellites (if outdoors).
Properties
You can set the below properties in the UI part of the builder.
- DistanceInterval - it's a sensor dist interval value which is set to 5 by default.
- Enabled - it's a boolean value which is set to true by default.
- TimeInterval - it's a sensor time interval value which is set to 60000 by default.
Block Properties
You can set the below blocks properties in the blocks section of the builder.
Accuracy
The most recent measure of accuracy, in meters. If no value is available, 0 will be returned.
Altitude
The most recently available altitude value, in meters. If no value is available, 0 will be returned.
AvailableProviders
List of available service providers, such as gps or network. This information is provided as a list and in text form.
CurrentAddress
Provides a textual representation of the current address or "No address available".
DistanceInterval
Determines the minimum distance interval, in meters, that the sensor will try to use for sending out location updates. For example, if this is set to 5, then the sensor will fire a LocationChanged event only after 5 meters have been traversed. However, the sensor does not guarantee that an update will be received at exactly the distance interval. It may take more than 5 meters to fire an event, for instance.
Enabled
Indicates whether the user has specified that the sensor should listen for location changes and raise the corresponding events.
HasAccuracy
If `true
HasAltitude
If `true
HasLongitudeLatitude
If `true
Latitude
The most recently available latitude value in degrees reported to 5 decimal places. If no value is available, 0 will be returned. Latitude is a value between 90 (north) and -90 (south), where 0 marks the Equator.
Longitude
The most recent available longitude value in degrees reported to 5 decimal places. If no value is available, 0 will be returned. Longitude is a value between 180 (east) and -180 (west), where 0 marks the Prime Meridian.
ProviderLocked
The device will not change the service provider. It is possible for a device to switch service providers when the current provider is unable to provide adequate location information. `ProviderLocked` is a Boolean value: true/false. Set to `true
ProviderName
Indicates the source of the location information. If there is no provider, the string "NO PROVIDER" is returned. This is useful primarily for debugging.
TimeInterval
Determines the minimum time interval, in milliseconds, that the sensor will try to use for sending out location updates. However, location updates will only be received when the location of the phone actually changes, and use of the specified time interval is not guaranteed. For example, if 1000 is used as the time interval, location updates will never be fired sooner than 1000ms, but they may be fired anytime after.
Methods
You can set the below method blocks in the blocks section of the builder.
LatitudeFromAddress
Derives latitude of given address
LongitudeFromAddress
Derives longitude of given address
Events
You can set the below event blocks in the blocks section of the builder.
LocationChanged
Indicates that a new location has been detected.
StatusChanged
Indicates that the status of the location provider service has changed, such as when a provider is lost or a new provider starts being used.