Hello Everyone,
With some help from many in the community (especially Xander Baker), we have put together a custom arcade expression to pass through values to Survey123 from Collector. The below example set works like a charm on Android/Windows devices, but on iOS devices the center function does not pass through and all of the points end up on null island.
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 = "arcgis-survey123://?itemID=<surveyid>";
url += "&field:name1=" + $feature["name1"] + "&field:name2=" + $feature["name2"];
url += "&field:name_new=" + $feature["name_new"] + "&field:rel_globalID=";
url += $feature["GlobalID"] + "&callback=https://collector.arcgis.app";
url += "¢er=" + lat + "," + lon;
Console(url);
return url;
}
var latlon = MetersToLatLon(Geometry($feature).X, Geometry($feature).Y);
var url = CreateURLSurvey(latlon[0], latlon[1]);
return url;Has anyone experienced this problem? We are running Collector 20.2.4 and Survey123 3.11.164 on the iPad and Collector 20.2.2 and Survey123 3.11.164 on the android/windows devices.
The center function does work on iOS when it is not an arcade expression.