The Geolocation object dispatches events in response to the device's location sensor.


If a device supports geolocation, you can use this object to obtain the current geographical location of the device. The geographical location is displayed on the device in the form of latitudinal and longitudinal coordinates (in WGS-84 standard format). When the location of the device changes, you can receive updates about the changes. If the device supports this feature, you will be able to obtain information about the altitude, accuracy, heading, speed, and timestamp of the latest change in the location.


This feature is supported only on mobile devices. It is not supported on desktop. You can test for support at run time using the Lib.Media.Sensors.Geolocation.isSupported property.


Note: To enable Geolocation in iOS, ensure that you add a key-value pair to the plist/dict element in the plist application xml file.


Geolocation object inherited from EventDispatcher


Can be created with method new:

Lib.Media.Sensors.Geolocation.new()

Creates a new Geolocation instance.



Geolocation has properties:

desiredAccuracy

This property determines the accuracy of the geolocation data on iOS. Setting pausesLocationUpdatesAutomatically to false can cause battery drain as it keeps fetching geolocation data. Accuracy can be set to LOCATION_ACCURACY_BEST_FOR_NAVIGATION, LOCATION_ACCURACY_BEST, LOCATION_ACCURACY_NEAREST_TEN_METERS, LOCATION_ACCURACY_HUNDRED_METERS,  LOCATION_ACCURACY_THREE_KILOMETERS based on the app's usage scenario. Set the property after calling requestPermission() and enabling location services in background. The default value of the property is LOCATION_ACCURACY_BEST which is the best level of accuracy available. 

Lib.Media.Sensors.Geolocation.isSupported

[static] [read-only] Whether a location sensor is available on the device (true); otherwise false.

Lib.Media.Sensors.Geolocation.permissionStatus

[static] [read-only] Permission status

locationAlwaysUsePermission

This property determines the access permission type usage of geolocation. The permission type can be Always or When In Use. If the property is set to false, it requests When In Use permission else it requests Always use permission. Set the property before calling requestPermission(). The default value of the property is false. (for iOS)

muted

[read-only] Specifies whether the user has denied access to the geolocation (true) or allowed access (false). When this value changes, a status event is dispatched.

pausesLocationUpdatesAutomatically

This property determines whether the geolocation services should pause due to app inactivity when application goes into background (on iOS). The value can be true or false. If the property is set to false, it ensures continous updates of geolocation services. Set the property after calling requestPermission() and enabling location services in background. The default value of the property is true. 


methods:

requestPermission()

Request permission to obtain location information, required on mobile devices.


setRequestedUpdateInterval(interval)

Used to set the time interval for updates, in milliseconds. The update interval is only used as a hint to conserve the battery power. The actual time between location updates may be greater or lesser than this value.Any change in the update interval using this method affects all registered update event listeners. The Geolocation object can be used without calling the setRequestedUpdateInterval method. In this case, the platform will return updates based on its default interval.


Note: First-generation iPhones, which do not include a GPS unit, dispatch update events only occasionally. On these devices, a Geolocation object initially dispatches one or two update events. It then dispatches update events when information changes noticeably. 

interval -  requested update interval. If interval <= 0, then any call to this method has no effect. 


Public constants:

Lib.Media.Sensors.Geolocation.LOCATION_ACCURACY_BEST

[static] The best level of accuracy available. "locationAccuracyBest"

Lib.Media.Sensors.Geolocation.LOCATION_ACCURACY_BEST_FOR_NAVIGATION

[static] The highest possible accuracy that uses additional sensor data to facilitate navigation apps. "locationAccuracyBestForNavigation"

Lib.Media.Sensors.Geolocation.LOCATION_ACCURACY_HUNDRED_METERS

[static] Accurate to within one hundred meters. "locationAccuracyHundredMeters"

Lib.Media.Sensors.Geolocation.LOCATION_ACCURACY_NEAREST_TEN_METERS

[static] Accurate to within ten meters of the desired target. "locationAccuracyNearestTenMeters"

Lib.Media.Sensors.Geolocation.LOCATION_ACCURACY_THREE_KILOMETERS

[static] Accurate to the nearest three kilometers. "locationAccuracyThreeKilometers"



Events: StatusEvent, GeolocationEvent.


Created with the Personal Edition of HelpNDoc: Free PDF documentation generator