Calculate Geopoint from list else use GPS location if other is selected

626
2
Jump to solution
09-07-2021 08:01 PM
ChrisRoberts2
Occasional Contributor III

Hi All

I have a form where a user selects a Wetland from a list and the geopoint location is calculated using a pulldata function from a list of centroids in a csv.  That bit works great!  However, the business has now asked to have "other" added to the list and then allow the user to enter another value.  My question is how can I get the geopoint to revert to the default  device GPS location if the user selects other from the list.  I cant get the syntax right, the map just seems to be blank and requires the user to click on the map and hit the gps button to locate the map.  In my use case scenario the geopoint quesion needs to be hidden from the user.

Cheers

Chris

0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Hi @ChrisRoberts2,

This should be possible using an additional few hidden questions to store the values before you set the geopoint and by using some if() statements and/or relevant statements. The problem you currently see is that if you have the values from the pulldata() function going straight to the geopoint, when "other" is selected there is no value, so the geopoint gets set with a null or 0,0 value. This wouldn't then automatically update if manually changed.

My suggestion would be, from the select one (I assume you are using) pass the values into the pulldata() calc and make this question hidden. Then, have a new question that is relevant, that if "other" is selected, allows a text box to enter the coordinates manually (you could even use two text boxes, one for lat and long each). Then have another hidden question that combines the data from the above two questions into one (you can use an if() statement for this). That way there will always be a coordinate in this one question either from pulldata() or user entered (but this is hidden to user) and use that value to set the geopoint.

Does that make sense?

If you need further help, please share your XLSForm (xlsx file and media folder CSV files) and I can take a futher look and provide an example for your with your configuration.

Regards,

Phil.

View solution in original post

2 Replies
by Anonymous User
Not applicable

Hi @ChrisRoberts2,

This should be possible using an additional few hidden questions to store the values before you set the geopoint and by using some if() statements and/or relevant statements. The problem you currently see is that if you have the values from the pulldata() function going straight to the geopoint, when "other" is selected there is no value, so the geopoint gets set with a null or 0,0 value. This wouldn't then automatically update if manually changed.

My suggestion would be, from the select one (I assume you are using) pass the values into the pulldata() calc and make this question hidden. Then, have a new question that is relevant, that if "other" is selected, allows a text box to enter the coordinates manually (you could even use two text boxes, one for lat and long each). Then have another hidden question that combines the data from the above two questions into one (you can use an if() statement for this). That way there will always be a coordinate in this one question either from pulldata() or user entered (but this is hidden to user) and use that value to set the geopoint.

Does that make sense?

If you need further help, please share your XLSForm (xlsx file and media folder CSV files) and I can take a futher look and provide an example for your with your configuration.

Regards,

Phil.

ChrisRoberts2
Occasional Contributor III

Thanks Phil

As often happens, after I posted I had another crack and managed to suss it!

I basically added another hidden and null geopoint question and a couple of calculate questions to formulate the lats and longs.  Then for the "primary" geopoint I placed a calculation so that if the answer to the select question was 'Other' use the second geopoint location else use  the lats and longs from the csv.

ChrisRoberts2_0-1631140956222.png

 

0 Kudos