Browse the docs

Get current location

Reads the Mac's current latitude, longitude and accuracy from Location Services.

Get the current location into into

Keyboard Maestro: GetLocation

Details #

Asks macOS where the Mac is and waits for a fix. The output is an object with latitude, longitude and accuracy (the accuracy in metres).

If you give into, it also sets these variables. With into set to here:

  • here: the text latitude,longitude, like 51.5007,-0.1246.

  • hereLatitude, hereLongitude: numbers.

  • hereAccuracy: a number, in metres.

The note of the step is the same latitude,longitude text.

Parameters #

ParameterTypeRequiredValuesWhat it does
intotextThe variable name, or prefix, as described above.
timeoutnumberHow many seconds to wait for a location. The default is 10. It is held to at least 1 and to at most 1 second under the step's own timeout.

Every step also accepts label, onFailure, timeout and dryRunSafe.

Examples #

Show where the Mac is (asks for Location Services the first time)
Do
  1. Get the current location
  2. Show “At {{hereLatitude}}, {{hereLongitude}} (within …” for 4 s
Open in Switchboard to try it

Gotchas #

  • If no location arrives in time, the step fails with "the Mac didn't report a location within N s". Steps have a 10 second timeout unless you set one, which also limits the wait, so raise the step's timeout along with timeout when a fix is slow.

  • Check accuracy before relying on a result; it is the error radius in metres.

  • In a dry run the step is simulated and into is set to empty text and the other variables are not set.

See also #

Show message, Send HTTP request