Provides access to the location information.
Refer to the topics entitled cf2:Geolocation and cf2:Geolocator for further information.
Attribute | Description | Type | Default | Options | Use |
---|---|---|---|---|---|
accuracy | Specifies the initial accuracy of the location information. The default value of 'normal' indicates that the normal accuracy is acceptable. The value of 'high' means that the accuracy should be greater than normal. This setting may result in a slower response time and increased power consumption. On the client-side, the attribute is represented by the enableHighAccuracy property. | xs:string | normal | high, normal | optional |
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. A value of 'unlimited' will allow any cached information to be used. On the client-side, the attribute is represented by the maximumAge property. | xs:long or xs:string | 600000 | unlimited | optional |
timeout | Specifies the initial timeout, in milliseconds, i.e. the length of time to wait after requesting a location and before reporting a time out error. On the client-side, the attribute is represented by the timeout property. | xs:long | 20000 | optional |
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/2002/06/xhtml2"
xmlns:ui="http://www.volantis.com/xmlns/2009/07/cf2/ui"
xmlns:cf2="http://www.volantis.com/xmlns/2009/07/cf2"
xmlns:cst="http://www.volantis.com/xmlns/2009/07/cf2/template"
xmlns:mcs="http://www.volantis.com/xmlns/2006/01/xdime/mcs"
xmlns:sel="http://www.w3.org/2004/06/diselect"
xmlns:xforms="http://www.w3.org/2002/xforms">
<head>
<title>Geolocator</title>
<xforms:model>
<xforms:submission id="submissionId"/>
</xforms:model>
</head>
<body>
<sel:select>
<sel:when expr="mcs:feature('cf2:Geolocation')">
<cf2:geolocator id="locator" accuracy="normal" timeout="10000" max-age="20000"/>
<table>
<tr>
<td>Latitude</td>
<td>
<cst:value property-value="locator#position" path="coords.latitude"/>
</td>
</tr>
<tr>
<td>Longitude</td>
<td>
<cst:value property-value="locator#position" path="coords.longitude"/>
</td>
</tr>
<tr>
<td>Altitude</td>
<td>
<cst:value property-value="locator#position" path="coords.altitude"/>
</td>
</tr>
<tr>
<td>Accuracy</td>
<td>
<cst:value property-value="locator#position" path="coords.accuracy"/>
</td>
</tr>
<tr>
<td>AltitudeAccuracy</td>
<td>
<cst:value property-value="locator#position" path="coords.altitudeAccuracy"/>
</td>
</tr>
<tr>
<td>Heading</td>
<td>
<cst:value property-value="locator#position" path="coords.heading"/>
</td>
</tr>
<tr>
<td>Speed</td>
<td>
<cst:value property-value="locator#position" path="coords.speed"/>
</td>
</tr>
<tr>
<td>Error</td>
<td>
<cst:value property-value="locator#error" path="code"/> ( <cst:value
property-value="locator#error" path="message"/> ) </td>
</tr>
<tr>
<td>Timestamp</td>
<td id="last_aquisition_timestamp"/>
</tr>
<tr>
<td>CONFIGURATION</td>
<td>
<ui:button> Apply
<cf2:on event="cf2:activate">
<cf2:param name="locator" component="locator"/>
var enteredAccuracy = V$E('accuracyinput').value;
var enteredTimeout = V$E('timeoutinput').value;
var enteredMaxAge = V$E('maxageinput').value;
if('' !== enteredAccuracy) {
locator.opGet('accuracy').set(enteredAccuracy);
}
if('' !== enteredTimeout) {
locator.opGet('timeout').set(+enteredTimeout);
}
if('' !== enteredMaxAge) {
locator.opGet('max-age').set(+enteredMaxAge);
}
</cf2:on>
</ui:button>
</td>
</tr>
<tr>
<td>accuracy</td>
<td>
<xforms:input ref="accuracyinput" id="accuracyinput" size="5">
<xforms:label/>
</xforms:input>
</td>
</tr>
<tr>
<td>timeout</td>
<td>
<xforms:input ref="timeoutinput" id="timeoutinput" size="5">
<xforms:label/>
</xforms:input>
</td>
</tr>
<tr>
<td>max-age</td>
<td>
<xforms:input ref="maxageinput" id="maxageinput" size="5">
<xforms:label/>
</xforms:input>
</td>
</tr>
</table>
<div>
<ui:button> Start <cf2:on event="cf2:activate" do="locator#start"/>
</ui:button> | <ui:button> Stop <cf2:on event="cf2:activate" do="locator#stop"/>
</ui:button> | <ui:button> Update <cf2:on event="cf2:activate" do="locator#update"/>
</ui:button>
</div>
<mcs:script type="text/javascript">
V$C.linking(function(c) {
var locator = c.get("locator");
locator.opGet("position").evtRegister(function(e) {
if (e.opNewValue) {
document.getElementById("last_aquisition_timestamp").innerHTML = e.opNewValue.timestamp;
}
}, "cf2:propertyChange");
});
</mcs:script>
</sel:when>
<sel:otherwise>
<div> The cf2:Geolocation feature is not supported on this device. </div>
</sel:otherwise>
</sel:select>
</body>
</html>