ztcl::locationlocation
Gives the position of a phone.
ztcl::location SUBCOMMAND ?ARG ...?
Description
The position of a phone: the permission of the OS, one reading, or a reading at each move. The command is not a package: it exists when the embedder turns on the capability location, and a child interp has it only when its parent has it.
The services come from Interp.device_host of the embedder, which ztk fills on iOS and macOS with CoreLocation, and on Android. A host with no location service, as the ztcl program on a desktop, gives the error ZTCL LOCATION UNAVAILABLE. With no permission of the user, the command gives no position: the script gets {error denied}.
The examples of this page run with --allow location and no host, so each one is an error.
Subcommands
| Subcommand | Description |
|---|---|
ztcl::location status | Gives the permission and whether the location service is on. |
ztcl::location request | Asks the user for the permission. |
ztcl::location get | Gives one position. |
ztcl::location watch | Runs a script at each move. |
ztcl::location cancel | Stops a handle. |
Returns
The result of the subcommand.
Examples
% catch {ztcl::location status} msg opts; list $msg [dict get $opts -errorcode]
{the location is not available on this platform} {ZTCL LOCATION UNAVAILABLE}
Errors
% ztcl::location
wrong # args: should be "ztcl::location subcommand ?arg ...?"
-errorcode TCL WRONGARGS
% ztcl::location bogus
unknown or ambiguous subcommand "bogus": must be cancel, get, request, status, or watch
-errorcode TCL LOOKUP SUBCOMMAND
Facts
- Capability
location. A new interpreter does not have it until the host turns it on.- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.6
The full page: ztcl::location.