Using location from field maps in survey123

283
4
Jump to solution
a month ago
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
JosephRhodes2
Occasional Contributor II

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

@JosephRhodes2 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
4 Replies
JosephRhodes2
Occasional Contributor II

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
ChristopherCounsell
MVP Regular Contributor

@JosephRhodes2 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