Note, a new XPath function (ala here()
) for capturing the current GPS location has been discussed (and rejected) previously. Specifically:
I think the custom XForms action orx:setlocation is the way to go instead of an XPath function, because obtaining a location can be assumed to an asynchronous operation, which would be very problematic in an XPath evaluator (it would have to block until a response is received or timeout has passed).
As noted by @ln there is the existing start-geopoint question type in XLSForm for doing a one-time location fix at the beginning of the form. And if you dont mind getting your hands dirty with XForm XML, you can also trigger capturing a GPS locations at later points in your form whenever a question is answered; from https://getodk.github.io/xforms-spec/#setting-a-static-value-when-a-nodes-value-changes
<input ref="/data/my_text">
<setvalue event="xforms-value-changed" ref="/data/my_text_changed">Value changed!</setvalue>
<odk:setgeopoint event="xforms-value-changed" ref="/data/my_current_location" />
</input>
(although as stated the odk:seteopoint
part isnt exposed in XLSForm, yet... Whereas the setvalue
bit is bascially what an XLSForm trigger gets turned into)