# "here()" function to return the current location

**URL:** <https://forum.getodk.org/t/here-function-to-return-the-current-location/46827>\
**Category:** Ideas\
**Created:** [May 11, 2024, 7:15am UTC](https://forum.getodk.org/t/here-function-to-return-the-current-location/46827 "2024-05-11T07:15:45Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Xiphware](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/xiphware/32/2587_2.png) [@Xiphware](https://forum.getodk.org/u/Xiphware)\
**Post date:** [July 15, 2024, 10:02pm UTC](https://forum.getodk.org/t/here-function-to-return-the-current-location/46827/4 "2024-07-15T22:02:44Z")

</div>

Note, a new XPath function (ala `here()`) for capturing the current GPS location has been discussed (and rejected) [previously](https://forum.getodk.org/t/spec-addition-proposal-location-preload/10768/9). 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](https://getodk.github.io/xforms-spec/#setting-a-static-value-when-a-nodes-value-changes)

```auto
<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](https://xlsform.org/en/#trigger) gets turned into)

---

_[View the full topic](https://forum.getodk.org/t/here-function-to-return-the-current-location/46827)._
