You can technically populate the choice/item list of a select_one with any arbitrary string as the value. This is a bit unusual and not typically recommended, mainly because - for select_multiple - the various selected choices are stored in a string with a space delimiter; so if you happen to have an option whose value contains a space, it rather throws things off, breaks the selected() function, etc. But for a select_one this is less a concern.
Try running this simple form on XLSForm Online to see an working example [guess where I live… ]:
Thank you @Xiphware that’s super helpful.
I’ve tried with the form you sent, but it is not showing anything on the map, just the regular answers on the data table. Am I missing something?
If you want to see the selected location on a map, you’d probably need to feed the selected gps location into a separate geopoint question and use it to pre-populate the widgets location. That’s not something I’ve tried, yet… (but check back tomorrow )
As to adding a custom label on the geopoint widget map with the city name, that’s beyond the scope of the defined geopoint control behavior. It may be possible in some implementations, but suffice to say it’s ‘non-standard’
As to adding a custom label on the geopoint widget map with the city name, that’s beyond the scope of the defined geopoint control behavior. It may be possible in some implementations, but suffice to say it’s ‘non-standard’
Sorry if I wasn’t clear, I wasn’t trying to add a custom label on the map. My objective is:
The geopoint question can take any input at the XForm level, but Collect only allows inputting coordinates either by accessing the GPS/network location sensor of the device or the user selecting a point on a map. Enketo has these features and also allows users entering coordinates manually.
The default question type only allows values, no dynamic lookups (so ${location} won’t work as a default value)
KoBo’s map feature only works based on the first geopoint question it encounters.
Actually, yes you can… In XForms any instance element binding can contain a calculation, including geopoints, although in the Kobo KPI form builder this ability is not exposed. But you can certainly have a geopoint result with a calculated value in an XML XForm (!), and with a bit of a fudge you can mimic the same in an XLSForm; see
In this XLSForm the geopoint has a calculation that picks up the gps string from your selected city. In order to prevent this being over-written I’ve had to make the question read_only, effectively disabling the map widget [aside, ideally you’d make this question relevant=false so the map doesn’t even get displayed, but as a side-effect (bug?) of some XForm clients, including Enketo, they dont bother running calculations of controls that are non-relevant. I must remember to talk to @martijnr about this…]. But the net result is you have a geopoint result in your form that is populated with the gps location of your selected city.
BTW, this is a lot cleaner to accomplish in an actual XML form, because there you can just specify the geopoint instance XML element and associated binding with the calculation, but no actual geopoint control. So the desired geopoint is in the final submission result but nothing is actually displayed in the Collect UI.
Again, whether or not your result viewer (eg Kobo map feature) shows the geopoint ${city} label or not on the map is beyond the scope of the XForm definition.
Holy smokes! That’s perfect, exactly what I was hoping for.
We’ll have to add support for calculate questions (currently not supported on our client, Tella), but once it’s done, it will definitely increase usability for some of our projects. Admins will be able to get both the name of the city in the data table, and the geopoint on the map.
Genius work, @Xiphware. calculates definitely work on non-calculate questions as well, and the result definitely shows the GPS coordinates on the KoBoToolbox map as desired.
I’m pasting the short form definition here for reference so people don’t have to download the XLS:
Its not perfect; unfortunately you are still having to present users with a disabled map widget in the form. But unless you want to delve into the murky, wild, pirate-invested waters of raw XML forms, its probably about the best you can do within the safer confines of XLSForms
Sorry, I misunderstood that the issue was about creating a calculation with a geopoint datatype without a form control.
There is a super secret feature in XLSForm (don’t tell anyone). You can use the bind::type column to override the type of a question. In this case you’d want to use the value “geopoint” in that column.
P.S. The bug discovered is still valid and will be fixed eventually.
@raph, @tinok please have a go and make sure the new version still shows up in your Kobo map view. thnx.
Note, you might need to wait till Kobo updates its Enketo fork before trying to preview this new version in Kobo. If you try now you’ll get a “TypeError: this.question is null” error, which is bug 607 that was just fixed. But the above link to XLSForm Online will show how it ultimately looks.