Passing centroid from a feature in Field Maps to repeat group geopoint in Survey123 (apps)

1483
3
05-04-2021 03:30 PM
Kiyomi_Holman
New Contributor II

Hello,

I am trying to pass the centroid of a feature from the Field Maps field app to the Survey123 field app through the URL parameters. I have poached the following arcade expressions to find the lat/lon:

var originShift = 2.0 * PI * 6378137.0 / 2.0;
var lat = (Centroid($feature).Y / originShift) * 180.0;
lat = 180.0 / PI * (2.0 * Atan( Exp(lat * PI / 180.0)) - PI / 2.0);

return lat
var originShift = 2.0 * PI * 6378137.0 / 2.0;
var lon = (Centroid($feature).X / originShift) * 180.0

return lon

 

then pass that in to my URL parameter as "...&?center={expression/expr0},{expression/expr1}"

When I test these expressions in the arcade dialogue they return the correct coordinates, but the geopoint is still centered on my iPad's location when it opens Survey123. I was wondering if this is because my geopoints are in a repeat group, or if there are some known bugs when the geopoints are in a repeat, like it has to go to the 'name' field in the XLSform or something?

The points are collecting land use information on a single parcel of land so it would be ideal to keep it to one survey submission per parcel. I would like to have each new record start at the centroid, then the user can move it around to collect the specific survey data on the parcel. My geopoint question is set to required, and I built the survey in Connect. Not sure how much info to supply but I'm happy to provide more if necessary!

Unrelated, but I'm also having trouble with the callback function to return to the Field Maps app once I submit the survey. It's written this way at the moment: "...&callback=fieldmaps.arcgis.app://" in the parameters, but to no avail.

Any help is appreciated, thanks!

3 Replies
DougBrowning
MVP Esteemed Contributor

With repeats I had better luck passing into a top level placeholder field, then in the repeat inherit that placeholder field.

Hope that does it I do not pass coordinates much.

Kiyomi_Holman
New Contributor II

Thank you for the suggestion! I think I just tried what you described, but let me check:

I created a geopoint outside my repeat to pass the center coordinates to, then set the default of the repeats to this geopoint. Is this what you meant?

I do not want this dummy geopoint to show on my form so I also tried setting the appearance to hidden, and in another attempt I made the type itself hidden instead of geopoint. I then tried to see if it would work with it displayed with normal settings anyway. None of these attempts have successfully passed the coordinates to my geopoint(s). I have also se the default to null as is stated in the documentation, but then that just makes the map go away.

I am able to pass other information like parcel IDs, it's just the coordinates that aren't doing what I want which makes me more suspicious that it has to do with the arcade expression, url parameters, or app settings...or my brain haha

DougBrowning
MVP Esteemed Contributor

You can not pass into a hidden field - I actually had this in my form today.  Using the style of hidden I am not sure if that works or not since it is new.  Have you tried that?

If you do not care about the main form point at all then you could just pass the coords to a text field then use that in the repeat default/calc.

Worst case wrap a group around the main geopoint and set it to compact (closed) and no one will really see it.

Hope that helps