cf2:Geolocator

Purpose

This component uses the API defined by the cf2:Geolocation component and provides a simple mechanism for obtaining the location information within a Client Framework 2 application. It exposes the current position, error information and options as properties that can be used by other components.

Exported Features

cf2:Geolocator

Imported Features

cf2:Geolocation, cf2:ObservablePropertySet

Markup

This component is provided by the cf2:geolocator element.

JavaScript

This component provides the following methods:

start()

Starts the process of watching the position of the device. It is an error if the component is already monitoring the current position.

stop()

Stops the process of watching the position of the device. It is an error if the component is not monitoring the current position.

update()

Obtains the current position. This can be called at any time and is not affected by whether the component is already watching the current position or not.

Properties

The following observable properties provide access to the results of attempting to acquire the current position.

Property Description Type Access
position The current position as acquired by the component. The value of the property will be updated every time a new position is acquired. If a position has not been acquired, then the value of the property is null. Position read
error Indicates whether an error occurred on the previous attempt to acquire the location information; null if an error has not occurred. PositionError read

The following observable properties provide access to and control over the options used when acquiring the position information. If the component is watching the current position, then changing any of these properties will cause it to restart the watching process to allow for new settings to take effect.

Property Description Type Access
accuracy The required accuracy of the location information. The property supports two values: 'normal' and 'high'. The initial value of the property equals to the value of the accuracy attribute. The value of this property is used to set the enableHighAccuracy option. If the property is set to 'normal', then enableHighAccuracy is set to 'false'. If the property is set to 'high', then enableHighAccuracy is set to 'true'. string read/write
max-age If there is no cached location or it is older than the maximum age, then a new location will be requested; otherwise the cached location will be returned. The initial value of the property equals to the value of the max-age attribute. If the attribute is set to 'unlimited', then the property is set to 'Infinity'. The value of the property sets the maximumAge option. long read/write
timeout The length of time, in milliseconds, to wait for a position information to be acquired. The initial value of the property equals to the value specified by the timeout attribute. The value of this property is used to set the timeout option. long read/write

Related topics