LocationSensor Component


Properties

accuracy
  The LocationSensor will be able to locate the device with a varying degree of confidence, based on the quality of satellite, cell towers, and other data used to estimate location. The Accuracy value is the radius in meters around the sensor's detected location. The device has a 68% chance to be located within this radius. More precise location detection will result in a smaller accuracy number, which allows the app to have more confidence where the device is actually located. If the accuracy is not known, the return value is 0.0
Data type: number
Designer Writable false
Code Writeable false
Code Readable true let variable = locationsensorName.accuracy

altitude
  Altitude of the device measured in meters, if available. Altitude is measured from the World Geodetic System 84 reference ellipsoid, not sea level. Note that it is difficult for devices to accurately sense altitude. Altitude reported on a phone/tablet can easily be off by 30 meters or more.
Data type: number
Designer Writable false
Code Writeable false
Code Readable true let variable = locationsensorName.altitude

availableProviders
  List of available service providers, such as gps or network. This information is provided as a list and in text form.
Data type: array
Designer Writable false
Code Writeable false
Code Readable true let variable = locationsensorName.availableProviders

currentAddress
  Physical street address of the device from Google's map database. The address might not always be available from the provider, and the address reported may not always be of the building where the device is located. If Google has no address information available for a particular location, this will return No address available.
Data type: string
Designer Writable false
Code Writeable false
Code Readable true let variable = locationsensorName.currentAddress

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 50, then the sensor will fire a LocationChanged event only after 50 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. It is also useful to check against Accuracy when using this property. When your device is moving, the accuracy of the detected location is constantly changing.
Data type: number
Designer Writable true <locationsensor name="locationsensorName" distanceInterval="0">
Code Writeable true locationsensorName.distanceInterval = 0
Code Readable true let variable = locationsensorName.distanceInterval

enabled
  If true, the LocationSensor will attempt to read location information from GPS, WiFi location, or other means available on the device. This setting does not control whether location information is actually available. Device location must be enabled or disabled in the device settings.
Data type: boolean
Designer Writable true <locationsensor name="locationsensorName" enabled="true">
Code Writeable true locationsensorName.enabled = true
Code Readable true let variable = locationsensorName.enabled

hasAccuracy
  If true, the device can report its accuracy level.
Data type: boolean
Designer Writable false
Code Writeable false
Code Readable true let variable = locationsensorName.hasAccuracy

hasAltitude
  If true, the device can report its altitude.
Data type: boolean
Designer Writable false
Code Writeable false
Code Readable true let variable = locationsensorName.hasAltitude

hasLongitudeLatitude
  If true, the device can report longitude and latitude. It is always the case that either both or neither are.
Data type: boolean
Designer Writable false
Code Writeable false
Code Readable true let variable = locationsensorName.hasLongitudeLatitude

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.
Data type: number
Designer Writable false
Code Writeable false
Code Readable true let variable = locationsensorName.latitude

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.
Data type: number
Designer Writable false
Code Writeable false
Code Readable true let variable = locationsensorName.longitude

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 to prevent providers from changing. Set to false to allow for automatic switching when necessary.
Data type: boolean
Designer Writable false
Code Writeable true locationsensorName.providerLocked = true
Code Readable true let variable = locationsensorName.providerLocked

providerName
  The current service provider. The provider will most likely be either GPS or network.
Data type: string
Designer Writable false
Code Writeable true locationsensorName.providerName = Test providerName
Code Readable true let variable = locationsensorName.providerName

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 30000 is used as the time interval, location updates will never be fired sooner than 30000ms, but they may be fired anytime after. Values smaller than 30000ms (30 seconds) are not practical for most devices. Small values may drain battery and overwork the GPS.
Data type: number
Designer Writable true <locationsensor name="locationsensorName" timeInterval="0">
Code Writeable true locationsensorName.timeInterval = 0
Code Readable true let variable = locationsensorName.timeInterval

class
  The styling class of the the component
Data type: string
Designer Writable true <locationsensor name="locationsensorName" class="Test class">
Code Writeable false
Code Readable false

id
  The styling id of the the component
Data type: string
Designer Writable true <locationsensor name="locationsensorName" id="Test id">
Code Writeable false
Code Readable false

name
  The name of the component that will be used to refer to it in code.
Data type: string
Designer Writable true <locationsensor name="locationsensorName" name="testComponent">
Code Writeable false
Code Readable false

Methods

Method name Description Parameters
latitudeFromAddress Derives latitude from the given locationName.
locationsensorName.latitudeFromAddress(locationName)
locationsensorName.latitudeFromAddress(Test locationName)
locationName string
longitudeFromAddress Derives longitude from the given locationName.
locationsensorName.longitudeFromAddress(locationName)
locationsensorName.longitudeFromAddress(Test locationName)
locationName string
addEventListener Method used to create event listeners.
See Events below for samples.
eventName string
eventCallbackFunction callback

Events

Event name Description Parameters
locationChanged Indicates that a new location has been detected. Speed is reported in meters/second Other values match their properties.
locationsensorName.addEventListener(
    "locationChanged",
    function (latitude, longitude, altitude, speed) {
        //Your code here
    }
)
latitude number
longitude number
altitude number
speed number
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.
locationsensorName.addEventListener(
    "statusChanged",
    function (provider, status) {
        //Your code here
    }
)
provider string
status string