Collector URL Scheme

1436
5
Jump to solution
12-24-2018 08:19 PM
ChaimSchwartz4
Occasional Contributor

The following URL successfully invokes the Collector app to create a new point in my map with a fixed pair of coordinates: 

arcgis-collector://?itemID=07d4865e6dfa433f8a6507fca71e94e6&center=35.666666,-120.66666

Does anyone know how I can have this URL built so that it passes the coordinates based on an existing (selected) feature?  The following two don't seem to work and I can't find documentation for this (Found this and  this)

arcgis-collector://?itemID=07d4865e6dfa433f8a6507fca71e94e6&center=%22{lat}%22,%22{lon}%22‍

arcgis-collector://?itemID=07d4865e6dfa433f8a6507fca71e94e6&center=%22${lat}%22,%22${lon}%22‍
Reply
0 Kudos
1 Solution

Accepted Solutions
ChaimSchwartz4
Occasional Contributor

Thank you Xander Bakker‌, I eventually got it to work. Some background - I was trying to have a collector url open the same map in collector, and create a new feature while passing both a location and a specific attribute from a selected feature in one feature layer, to a new feature in a different feature layer. One problem was that for some reason my arcade script for Lat/Long conversion, which worked fine for survey123, and was also successfully  running using the arcade "test", was not working for collector, not sure why, so I used your lat/lon conversion expression which worked great, thank you! The other problem was that I didn't correctly build the HTML URL encoding which is required for the collector URL (unlike the survey123 scheme) which was a little bit tricky. The following arcade expression works for me in the "new" (aurora) collector, hope it's helpful to someone out there because I was not able to find allot of documentation for the collector URL:

function MetersToLatLon(x, y) {
    // Converts XY point from Spherical Mercator EPSG:900913 to lat/lon in WGS84 Datum
     // Fuente: 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 text(lat+","+lon);
}


var latlon = MetersToLatLon(Geometry($feature).X, Geometry($feature).Y);


var url = "arcgis-collector://?itemID=07d4865e6dfa433f8a6507fca71e94e6&center="+ latlon
url = url + "&featureSourceURL=https://services.arcgis.com/pGoeHmYZOCXOU5IQ/arcgis/rest/services/Water_Utility_Map_Change_Request/F..."
url = url + "&featureAttributes=%7B%22assetID%22:%22"+$feature.assetID+"%22%7D"


return url‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

5 Replies
XanderBakker
Esri Esteemed Contributor

Can you elaborate on from where you are generating the URL? Is this in a pop-up of a web map (ArcGIS Online or Portal)? I notice the %22 in the URL. These are double quotes and probably are the reason that this is not working. Make sure that the coordinates in the lat and lon fields are valid decimal degrees.

XanderBakker
Esri Esteemed Contributor

In addition, I have some posts (unfortunately in Spanish) on how to create a link to other applications in the pop-up of ArcGIS Online using Arcade:

ChaimSchwartz4
Occasional Contributor

Thank you Xander Bakker‌, I eventually got it to work. Some background - I was trying to have a collector url open the same map in collector, and create a new feature while passing both a location and a specific attribute from a selected feature in one feature layer, to a new feature in a different feature layer. One problem was that for some reason my arcade script for Lat/Long conversion, which worked fine for survey123, and was also successfully  running using the arcade "test", was not working for collector, not sure why, so I used your lat/lon conversion expression which worked great, thank you! The other problem was that I didn't correctly build the HTML URL encoding which is required for the collector URL (unlike the survey123 scheme) which was a little bit tricky. The following arcade expression works for me in the "new" (aurora) collector, hope it's helpful to someone out there because I was not able to find allot of documentation for the collector URL:

function MetersToLatLon(x, y) {
    // Converts XY point from Spherical Mercator EPSG:900913 to lat/lon in WGS84 Datum
     // Fuente: 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 text(lat+","+lon);
}


var latlon = MetersToLatLon(Geometry($feature).X, Geometry($feature).Y);


var url = "arcgis-collector://?itemID=07d4865e6dfa433f8a6507fca71e94e6&center="+ latlon
url = url + "&featureSourceURL=https://services.arcgis.com/pGoeHmYZOCXOU5IQ/arcgis/rest/services/Water_Utility_Map_Change_Request/F..."
url = url + "&featureAttributes=%7B%22assetID%22:%22"+$feature.assetID+"%22%7D"


return url‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

XanderBakker
Esri Esteemed Contributor

Thanks for posting back the solution. You can mark your answer as the correct one. This way other people will be able to find your solution easier. 

Reply
0 Kudos
BenBaker1
New Contributor III

Does this method still work with the new Collector links (e.g. https://collector.arcgis.app?itemID=....&referenceContext=center&center=....,....) outlined here: Deploy your map—Collector for ArcGIS | Documentation 

I'm trying to launch to Collector from an Operations Dashboard and have the URL configured in the web map Popup, but Collector is not centering on the point when it launches from the Dashboard. 

Reply
0 Kudos