Select to view content in your preferred language

Using location from field maps in survey123

1142
5
Jump to solution
03-27-2024 01:33 PM
SeanOTooleCT
New Contributor

I have a field map with a point layer and when a user selects a point, the pop up contains a link that launches survey123 and automatically fills in some of the survey fields based on information from field maps using the field:fieldname parameter. I assumed that the location of the point in field maps would be used as the location of the entry in survey123, but instead it uses the user's location. Is there a way to use the field maps point location as the survey123 location?

0 Kudos
2 Solutions

Accepted Solutions
JRhodes
Frequent Contributor

Hi Sean, here's how we do that:

  1. Add &center=<lat>,<long> to the end of the link that opens Survey123 (ex:  &center=40.3798956137812,-122.98043757805).
  2. On the geopoint question in your survey's XLSform, set required=yes, readonly=yes, and default=null.

You'll need to use an Arcade expression to get the lat-long values. If your Field Maps point data happens to be in 4326 (WGS 84), you can just add 

 

"&center=" + Geometry($feature).y + ',' + Geometry($feature).x

 

to the expression that builds your link (or if you happen to already have lat/long values elsewhere in the table, you can just use those, of course).
 
If your Field Maps point data is in another projection, it gets a bit trickier because you have to convert to lat/long. Let me know if this is the case and I'll see if I can help you convert those values in your popup.

View solution in original post

0 Kudos
ChristopherCounsell
MVP Regular Contributor

@JRhodes is correct with the URL values, but if your data is in WGS84 (Web Meractor) the Geomtetry($feature) returns projected coordinates instead of the necessary decimal degrees. You'll need to convert them.

function MetersToLatLon(x, y) {
    var long = (x / 20037508.34) * 180;
    var lat = (y / 20037508.34) * 180;
    lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
    return{
        y: lat,
        x: long
    }
}
var latlon = MetersToLatLon(Geometry($feature).X, Geometry($feature).Y);

// assuming you have a URL already and adding parameters
url = url + "&center=" = latlon.y + "," + latlon.x

 

Other examples of that here and elsewhere on the community forums

https://support.esri.com/en-us/knowledge-base/how-to-launch-and-populate-a-survey123-for-arcgis-surv...

 

View solution in original post

0 Kudos
5 Replies
JRhodes
Frequent Contributor

Hi Sean, here's how we do that:

  1. Add &center=<lat>,<long> to the end of the link that opens Survey123 (ex:  &center=40.3798956137812,-122.98043757805).
  2. On the geopoint question in your survey's XLSform, set required=yes, readonly=yes, and default=null.

You'll need to use an Arcade expression to get the lat-long values. If your Field Maps point data happens to be in 4326 (WGS 84), you can just add 

 

"&center=" + Geometry($feature).y + ',' + Geometry($feature).x

 

to the expression that builds your link (or if you happen to already have lat/long values elsewhere in the table, you can just use those, of course).
 
If your Field Maps point data is in another projection, it gets a bit trickier because you have to convert to lat/long. Let me know if this is the case and I'll see if I can help you convert those values in your popup.
0 Kudos
KelseyWong
New Contributor

Hi Joseph, I'm having a similar issue but with pulling in the z value and horizontal accuracy from Field Maps into Survey123. The S123 form is set up to capture the x, y, z values, along with the horizontal accuracy of the point that is created in Field Maps and hyperlinks to a Survey123 form. When the S123 form is initiated directly through the Survey123 app all of those values are captured correctly, however, when the form is initiated from hyperlink in Field Maps, only the x and y values are carried over. Any ideas on how I can bring in the z and horizontal accuracy as well? Thanks

0 Kudos
ChristopherCounsell
MVP Regular Contributor

@JRhodes is correct with the URL values, but if your data is in WGS84 (Web Meractor) the Geomtetry($feature) returns projected coordinates instead of the necessary decimal degrees. You'll need to convert them.

function MetersToLatLon(x, y) {
    var long = (x / 20037508.34) * 180;
    var lat = (y / 20037508.34) * 180;
    lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
    return{
        y: lat,
        x: long
    }
}
var latlon = MetersToLatLon(Geometry($feature).X, Geometry($feature).Y);

// assuming you have a URL already and adding parameters
url = url + "&center=" = latlon.y + "," + latlon.x

 

Other examples of that here and elsewhere on the community forums

https://support.esri.com/en-us/knowledge-base/how-to-launch-and-populate-a-survey123-for-arcgis-surv...

 

0 Kudos
SeanOTooleCT
New Contributor

Thank you both so much for the very helpful responses!

ChristopherCounsell
MVP Regular Contributor

did you get it working? If so please mark the comment that helped you as the answer so the post is closed.

Cheers, Chris

0 Kudos