Capture current GPS lat,lon and copy to clipboard

Hello everyone,

I’m trying to write a shortcut to capture the current GPS coordinates and copy them to the clipboard. I’m struggling to get the location details extracted. I’m getting an error (shown in the attachment pic). Any guidance would be greatly appreciated.

Thanks

You’re trying to get the longitude of the latitude. Try using magic variables instead.

2 Likes

Just for info, the reason for the error is that after getting the current location this location is then passed to the get details action which extracts the latitude. But that latitude is then passed to the get details action which tries to get the longitude from it, only it isn’t a location it is a latitude represented as a string of text. Hence the error.

It is possible to grab the location and pull each detail from it in the way you were starting to do above. However magic variables in Shortcuts’ predecessor, Worklow, simplified this process massively. Hence the succinctness of the solution posted by @RosemaryOrchard above.


Suggestions for Dealing with Conversion Errors

If you ever get conversion errors, go back and check the little lines between shortcut steps. If there’s a line going down, that’s the input to the next action. Also tap on an action title to view it’s documentation. Sometimes actions will take in one type of object and pass out a different type of object. Sometimes they simply pass through what they received. Sometimes, they pass out nothing at all. Understanding how your data flows through the actions is one of the foundational elements of building shortcuts.

Dig Deeper with the Content Graph

Once you have some familiarity with how that works, you can also check out the content graph action. That action gives you some insight into what implicit conversions the shortcut could make with what the content graph action is receiving at that point. It even allows you to drill in and explore underlying values that are not always immediately visible in the top level of shortcuts. Sometimes you can convert formats and work with files to get access to data that is there but seems inaccessible to shortcuts :nerd_face:

1 Like

Thanks so much! That definitely gets me going and gives me some knowledge about how to do more.

If you use Drafts, it may be simpler to build there or adapt one of the existing actions:

https://actions.getdrafts.com/a/1Mx

https://actions.getdrafts.com/a/1Mw

https://actions.getdrafts.com/a/1Hm

1 Like