Select to view content in your preferred language

Show Lat/Lon coordinates for last know location?

1000
2
Jump to solution
10-22-2024 11:34 AM
MiltonSolano
Frequent Contributor

Hi Folks,

I have Location Sharing active with Field Maps and Survey123 app. My users are using a custom webmap I developed to monitor field crew. In a recent followup meeting, they suggested me if the lat/lon position for the last known location can be shown on the popup (see attached). I thought it was a piece of cake to add that info. After looking into the sharing location view, I noticed there's no data for lat/lon positions. All hosted layer contains lat/lon columns, but not the location sharing views. How I can I enable these columns?

Any suggestions on how to show these two really important pieces of data for location?

Thanks!

MJ

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

The most reliable way it to use Arcade so that it is dynamic.  Columns would just be static text or numbers so if someone moves the point later they are off.  Arc stores the actual coords in the Shape field.

Assumes map is web Mercator map and want to display WGS84.

CurrentLat
var originShift = 2.0 * PI * 6378137.0 / 2.0;
var lat = (Geometry($feature).y / originShift) * 180.0;
lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
return lat;

CurrentLong
var originShift = 2.0 * PI * 6378137.0 / 2.0;
var lon = (Geometry($feature).x / originShift) * 180.0;
return lon;

 

hope that helps

View solution in original post

2 Replies
DougBrowning
MVP Esteemed Contributor

The most reliable way it to use Arcade so that it is dynamic.  Columns would just be static text or numbers so if someone moves the point later they are off.  Arc stores the actual coords in the Shape field.

Assumes map is web Mercator map and want to display WGS84.

CurrentLat
var originShift = 2.0 * PI * 6378137.0 / 2.0;
var lat = (Geometry($feature).y / originShift) * 180.0;
lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
return lat;

CurrentLong
var originShift = 2.0 * PI * 6378137.0 / 2.0;
var lon = (Geometry($feature).x / originShift) * 180.0;
return lon;

 

hope that helps

MiltonSolano
Frequent Contributor

Hi @DougBrowning ,

It worked just fine and it did what I needed (see screenshot). I didn't figure out I was able to extract location from the geometry feature.x and feature.y data. Thanks for sharing the code.

MS