transfer polygon from feature layer to survey123

258
0
03-21-2023 01:35 AM
tendtreesTC
New Contributor III

Hi there,

I have been given a view to a feature layer containing a number of polygon assets.

I need to create an audit against these assets and as I only have view access the best option is to create an audit survey in survey123 and use a popup to send the relevant data across.

This has worked fine in the past for point data however, I have never had to send polygon geometry across.

I found a number of posts relating to this but have not been able to make them work.

below is an example of the code I have been using for point data:

function MetersToLatLon(x, y) {
// Converts XY point from Spherical Mercator EPSG:3857(Web Mercator Auxiliary Sphere) to lat/lon in WGS84 Datum (EPSG:4326).
// Source: http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
var originShift = 2.0 * PI * 6378137.0 / 2.0;

var lon = (x / originShift) * 180.0;
var lat = (y / originShift) * 180.0;

lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
return [lat, lon];
}
function CreateURLSurvey(lat, lon) {
var url_scheme = "https://survey123.arcgis.app?itemID=a7e89264efb44ade9d4639eb37ec3aca";
var url = url_scheme + "&field:tree_id="+DomainName($feature,"OBJECTID")
+"&field:site_name="+Replace($feature.address_full,' ','_')
+"&field:species="+Replace(DomainName($feature,"botanical_name"),' ','_')
;// Repeat this line as many times as required based on how many fields you want populated. For this example AssetID will be populated from otherfeatid
var url = url + "&center=" + lat + "," + lon;// This is the line that defines the location
Console(url);
return url;
}

var latlon = MetersToLatLon(Geometry($feature).X, Geometry($feature).Y);
var url = CreateURLSurvey(latlon[0], latlon[1]);
return url;

 

 

0 Kudos
0 Replies