Select to view content in your preferred language

Using device location for second geopoint when using <&center=> in URL scheme

468
5
04-09-2024 02:54 PM
JosephRhodes2
Occasional Contributor II

I have a survey with two geopoint questions:

  • The first geopoint represents the location of an asset in the field and is set by using the center parameter of the Survey123 URL scheme, and this is submitted as the geometry value for the the survey point. The user clicks a point in Field Maps, then the lat/long from that point is passed to the URL in the popup to become the survey point geometry. In other words, the survey point geometry is identical to the geometry of the clicked point in Field Maps. So far so good.
  • For the second geopoint question, we want to grab the device location and write lat/long to fields in the table. So we set the bind::esri:fieldType to null and set a calculation on two decimal fields using pulldata from the second geopoint.

The issue is that the "center" parameter seems to set the location of both geopoints when the survey is opened, rather than just setting the location of the non-null (default) geopoint question.

If the user clicks the locate button on the second geopoint, it recalculates and the correct values are passed to the decimal fields. But we need to automatically grab the device location without relying on the user clicking the second geopoint question (in fact, we would prefer to hide it entirely) to reset the location.

Is there a solution to this?

0 Kudos
5 Replies
DougBrowning
MVP Esteemed Contributor

Try setting the default value of the second geopoint to 0,0.  I use this in a form with 5 geopoints and it starts all the maps blank as seen here.

DougBrowning_0-1712703586631.png

I also have the code to calc distance and give the user a message (not a constraint since sometimes the GPS goes out in a canyon and then they get stuck so just a red warning)  if they are too far from where they are supposed to be if you need it.  

I personally flip this and send in the where they should be as a text lat long from Field Maps then compare that to where they are.  That way the form automatically goes to where they are with no interaction needed.  Also we can then see right on the map how far they were since the form is where they were.  May want to consider that.

hope that helps

JosephRhodes2
Occasional Contributor II

Thanks Doug. Looks like we won't be able to hide the question in that case, since the user will still need to click the locate button to populate the lat-long fields. This may be as good as it gets - at least we won't risk the user submitting the asset location on the second geopoint, so thanks.

Thanks for the other tips as well; we need the survey points to be coincident with the asset for this particular application but that's good to keep in mind for future applications.

0 Kudos
JosephRhodes2
Occasional Contributor II

@DougBrowning Setting the default to 0,0 still placed the second geopoint on the &center= value. However, setting calculate to null and bind::esri:parameters to calculationMode=always (then making the second geopoint required) worked for me. Thanks for putting me on the right track.

DougBrowning
MVP Esteemed Contributor

I would test edits if you set calculationMode=always since it may change it if anyone edits any field later on.

One idea I used in another form is pull the lat/long then set a constraint to make sure the second point is not in the same place as the first.

0 Kudos
JosephRhodes2
Occasional Contributor II

Thanks again Doug, very good point. I'm planning to use the pulldata("@property", 'mode') calculation on a hidden/null question to assign the survey mode to a variable, then use that variable in the relevant column for the second geopoint and the lat/long fields populated from it (e.g., ${survey_mode}!='edit')). This way those fields will only be calculated on initial submission.