This article accompanies this sample form. Please read the following and test the sample form. Either save a copy of the sample form in your Google Drive or download as an Excel workbook.
Aside from GPS coordinates being analytically valuable in research, they can be invaluable as a data verification measure in longitudinal studies. Collecting GPS coordinates in a geopoint field in SurveyCTO is just the start of what is possible.
In this tips and tricks article, I’ll show you how you can launch Google Maps using an HTML link on an Android device using SurveyCTO Collect, to get directions to pre-loaded GPS coordinates. This could be especially useful if you are planning a midline or endline survey and you are wondering how your survey team will find each location that was visited during your baseline survey.
Firstly, it is important to note that as of writing this, Google Maps on Android requires an internet connection to be launched and find a location or directions to that location, when using this HTML link approach. The ability to launch Google Maps and get directions to a location will still prove invaluable when it is available. When an internet connection is not available, there is a workaround, involving copying a set of coordinates from a text field which is populated using a calculation to provide a default value. These coordinates can then be pasted into Google Maps, which will provide driving directions, even when offline. This workaround is illustrated in the enumerator instructions in the accompanying sample form for this article. Also, conventional methods of locating an address can also be a fallback position.
Being able to launch Google Maps from a SurveyCTO form is facilitated by SurveyCTO’s HTML label support. Through including a clickable HTML link in a field’s label, you can call out to Google Maps on your device, to launch it, opening with directions to a location the user needs to find. GPS coordinates associated with each location can be pulled from attached pre-load data into the form using the pulldata() function in a calculate field. Those coordinates can then be concatenated (using the concat() function) to a partial URL to create a full, valid URL that opens Google Maps.
Implementing this solution
Review these instructions while viewing this sample form. The following steps apply:
1.) Prepare your GPS coordinates. Google Maps will accept coordinates in decimal degrees which is the same format that SurveyCTO will generate them in. The format should be “latitude longitude” (with a space in between, without the quotation marks). So either process your coordinates exactly like this and pre-load one value, or pre-load separate values and concatenate them together correctly inside your form.
2.) Concatenate your GPS coordinates with the appropriate URL and parameters in the Google Maps API guide. For example, if you wish Google Maps to open with directions, you will want to concatenate “https://www.google.com/maps/dir/?api=1&destination=” (without the quotation marks and no spaces) with your correctly formatted GPS coordinates. The end result should look like this, for example:
https://www.google.com/maps/dir/?api=1&destination=1.281817,36.815178
3.) Dynamically refer to this valid, concatenated URL in an HTML link. Let’s say the above partial link is concatenated with GPS coordinates inside a calculate field named “maps_directions”. The following HTML code can call out to and open Google Maps:
<a href="${maps_directions}" target="_blank">Click here for directions</a>
Note that your device might ask you which application to open the link in, because no default app is set for Google Maps links. The options may include your web browser, as well as Google Maps. You can tell Android to either Always open links like this in the selected application or do it Just once.
If you have an internet connection, Google Maps will load directions to get to the destination. When you’re done, switch back to SurveyCTO Collect and continue collecting data. If there is no internet connection, you may have to employ the workaround of copying coordinates from a text field, as already discussed. Otherwise, it is still advisable to supply your team with directions and addresses, which can also be pre-loaded into the form and displayed.
Promoting good quality GPS coordinates
There are also other things you can do to promote accuracy with the recording of GPS coordinates. For example, SurveyCTO’s distance-between() function can give you the distance in meters between sets of GPS coordinates. The syntax is “distance-between(${location1}, ${location2})” (without the quotation marks). Each individual set of coordinates should be formatted “latitude longitude” (without the quotation marks, with a space in between the two values). As an example, you could make additional question prompts based on the distance, to try to steer the SurveyCTO Collect user in the right direction. For example, a field that asks “Are you sure you are in the right place?”, with the relevance expression, ${distance_calculation} > 100 (relevant if the distance is greater than 100 meters).
Further, SurveyCTO’s geopoint field collects latitude, longitude, altitude (if provided by your device) and gps accuracy in a space-separated value list. The selected-at() function can be used to collect a value from a space separated value list based on the value’s position in the list. So, the expression, selected-at(${geopoint}, 3), will collect the accuracy value from a geopoint field in the current form instance. You could then display this information for the user of your form to see and make additional fields relevant based on this value, to prompt the user toward better quality GPS coordinates.
Consult the help topic on the geopoint field for more ways to promote good quality GPS data.
Consult the product documentation on using expressions in your forms to read about pulldata(), concat(), distance-between(), selected-at() and other functions which you can use in calculate fields in your form designs.
Do you have thoughts on this support article? We'd love to hear them! Feel free to fill out this feedback form.
0 Comments