Modules · Connectivity · Location
Location
Coordinates, addresses, routes and maps. Location models a geographic point as a
Location.Coordinate, pairs it with a postal
Location.Address to make a
Location.Place, and links places into a
Location.Route. It geocodes addresses into places and
back, streams the device's live GPS position, and renders maps with draggable
Location.Marker pins. Live readings are reactive: a
position or a lookup arrives asynchronously, so it is usually held in a STATE LOCKED
cell that stays pending until the device or service replies.
Contents
Types
Functions
- Location.Address.FromJson
- Location.Address.OptionalFromJson
- Location.Address.ToJson
- Location.AddressLineText
- Location.ApiClient.AddressLookup
- Location.ApiClient.AddressSearch
- Location.ApiClient.CoordinateLookup
- Location.ApiClient.PublicMapsApiKey
- Location.ApiKey
- Location.Container
- Location.Coordinate.FromJson
- Location.Coordinate.ToJson
- Location.FromJson
- Location.Lookup
- Location.MapMarker.Fixed
- Location.MapMarker.Interactive
- Location.MapMarker.Text
- Location.MapMarker.Title
- Location.MapRoute.Line
- Location.OptionalFromJsonString
- Location.PositionClient.Request
- Location.ReverseLookup
- Location.Route.FromJson
- Location.Route.OptionalFromJson
- Location.Route.ToJson
- Location.Service.Client.Send
- Location.ToJson
Types
Location.Address
A postal address: a display line together with optional structured parts.
Fields
| Field | Type | Description |
|---|---|---|
string | Text | The address as a single display line. |
optionalStreetNumber | Collection.Optional(Text) | Street number, if known. |
optionalStreetName | Collection.Optional(Text) | Street name, if known. |
optionalLocality | Collection.Optional(Text) | Town or city, if known. |
optionalAdministrativeAreaLevel1 | Collection.Optional(Text) | Top-level region such as a state, if known. |
optionalAdministrativeAreaLevel2 | Collection.Optional(Text) | Second-level region such as a county, if known. |
optionalCountry | Collection.Optional(Text) | Country, if known. |
optionalPostalCode | Collection.Optional(Text) | Postal or ZIP code, if known. |
optionalFormattedAddress | Collection.Optional(Text) | Provider-formatted full address, if known. |
Location.Coordinate
A geographic point as a latitude and longitude in degrees.
Fields
| Field | Type | Description |
|---|---|---|
latitude | Maths.Real | Degrees north of the equator. |
longitude | Maths.Real | Degrees east of the prime meridian. |
Example
LET Location.Coordinate london = Location.Coordinate 51.5074 -0.1278Location.Marker
A pin on a map: a coordinate with an optional title, text, and draggability.
Fields
| Field | Type | Description |
|---|---|---|
coordinate | Location.Coordinate | Where the marker sits. |
optionalTitle | Collection.Optional(Text) | Title shown for the marker, if any. |
optionalText | Collection.Optional(Text) | Description shown for the marker, if any. |
optionalDraggable | Collection.Optional(Logic.Maybe) | Whether the marker can be dragged, if specified. |
Location.Place
A resolved place: a coordinate together with an optional address.
Fields
| Field | Type | Description |
|---|---|---|
coordinate | Location.Coordinate | Where the place is. |
optionalAddress | Collection.Optional(Location.Address) | The address, if one was resolved. |
Location.Route
A journey from a start place to an end place, with optional waypoints in between.
Fields
| Field | Type | Description |
|---|---|---|
start | Location.Place | Where the route begins. |
end | Location.Place | Where the route ends. |
optionalWaypoints | Collection.Optional(Collection.Array(Location.Place)) | Ordered stops between start and end, if any. |
Functions
Location.Address.FromJson
Decodes an address from a JSON value.
Parameters
| Name | Type | Description |
|---|---|---|
optionalJson | Collection.Optional(Code.Language.Json.Value) | The JSON to decode. |
Returns
Returns Location.Address — the decoded address.
Location.Address.OptionalFromJson
Decodes an optional address from a JSON value, or none when absent.
Parameters
| Name | Type | Description |
|---|---|---|
optionalJson | Collection.Optional(Code.Language.Json.Value) | The JSON to decode. |
Returns
Returns Collection.Optional(Location.Address) — the decoded address, or none.
Location.Address.ToJson
Encodes an address as a JSON value.
Parameters
| Name | Type | Description |
|---|---|---|
address | Location.Address | The address to encode. |
Returns
Returns Code.Language.Json.Value — the address as a JSON object.
Location.AddressLineText
A single display line for an optional address, falling back to "Location" when none.
Parameters
| Name | Type | Description |
|---|---|---|
optionalAddress | Collection.Optional(Location.Address) | The address to render. |
Returns
Returns Text — the formatted address line, or "Location" when there is no address.
Location.ApiClient.AddressLookup
Looks up a single place for a query through the backend geocoding service.
Parameters
| Name | Type | Description |
|---|---|---|
query | Text | The address to look up. |
Returns
Returns Collection.Optional(Location.Place) — the matched place, or none.
Location.ApiClient.AddressSearch
Searches the backend geocoding service, returning every matching place.
Parameters
| Name | Type | Description |
|---|---|---|
query | Text | The search text. |
Returns
Returns Collection.Array(Location.Place) — all matching places, empty when there are none.
Location.ApiClient.CoordinateLookup
Reverse-geocodes a latitude and longitude into a place through the backend.
Parameters
| Name | Type | Description |
|---|---|---|
latitude | Maths.Real | Degrees north of the equator. |
longitude | Maths.Real | Degrees east of the prime meridian. |
Returns
Returns Collection.Optional(Location.Place) — the place at that point, or none.
Location.ApiClient.PublicMapsApiKey
Fetches the app's public Google Maps API key from the backend.
Returns
Returns Text — the maps API key, or the empty string when unavailable.
Location.ApiKey
The public Google Maps API key configured for the app.
Returns
Returns Text — the maps API key.
Location.Container
Groups map content so its markers and routes share one enclosing element.
Block
A block of map content — markers and routes — grouped together.
Returns
Returns nothing — it runs its block as one group.
Location.Coordinate.FromJson
Decodes a coordinate from a JSON value.
Parameters
| Name | Type | Description |
|---|---|---|
optionalJson | Collection.Optional(Code.Language.Json.Value) | The JSON to decode. |
Returns
Returns Location.Coordinate — the decoded coordinate, defaulting to zero when a field is missing.
Location.Coordinate.ToJson
Encodes a coordinate as a JSON value.
Parameters
| Name | Type | Description |
|---|---|---|
coordinate | Location.Coordinate | The coordinate to encode. |
Returns
Returns Code.Language.Json.Value — the coordinate as a JSON object with latitude and longitude.
Location.FromJson
Decodes a place from a JSON value.
Parameters
| Name | Type | Description |
|---|---|---|
optionalJson | Collection.Optional(Code.Language.Json.Value) | The JSON to decode. |
Returns
Returns Location.Place — the decoded place, defaulting fields that are missing.
Location.Lookup
Geocodes an address string into a place, or none when nothing matches.
Parameters
| Name | Type | Description |
|---|---|---|
addressString | Text | The address to look up. |
Returns
Returns Collection.Optional(Location.Place) — the matched place, or none.
Example
STATE LOCKED Location.Place found = Location.Lookup "10 Downing Street, London"Location.MapMarker.Fixed
Places a non-draggable marker on the map at a fixed coordinate.
Parameters
| Name | Type | Description |
|---|---|---|
coordinate | Location.Coordinate | Where the marker sits. |
Block
A block of Location.MapMarker.Title and Location.MapMarker.Text entries describing the marker.
Returns
Returns nothing — it renders a marker on the enclosing map.
Example
Location.MapMarker.Fixed london
Location.MapMarker.Title "London"
Location.MapMarker.Text "Capital of England"Location.MapMarker.Interactive
Places a draggable marker whose coordinate is bound two-way to a cell.
Parameters
| Name | Type | Description |
|---|---|---|
coordinate | Location.Coordinate | The coordinate cell, bound two-way so dragging the marker writes back to it. |
Block
A block of Location.MapMarker.Title and Location.MapMarker.Text entries describing the marker.
Returns
Returns nothing — it renders a draggable marker on the enclosing map.
Example
Location.MapMarker.Interactive pin
Location.MapMarker.Title "Drag me"pin.Location.MapMarker.Text
Sets the description text on the enclosing marker.
Parameters
| Name | Type | Description |
|---|---|---|
text | Text | The description to show. |
Returns
Returns nothing — it records the description on the enclosing marker.
Location.MapMarker.Title
Sets the title on the enclosing marker.
Parameters
| Name | Type | Description |
|---|---|---|
text | Text | The title to show. |
Returns
Returns nothing — it records the title on the enclosing marker.
Location.MapRoute.Line
Draws a straight line between two coordinates on the map.
Parameters
| Name | Type | Description |
|---|---|---|
startCoordinate | Location.Coordinate | Where the line begins. |
endCoordinate | Location.Coordinate | Where the line ends. |
Returns
Returns nothing — it draws a line on the enclosing map.
Example
Location.MapRoute.Line home officeLocation.OptionalFromJsonString
Parses a place from a JSON string, or none when the string is absent.
Parameters
| Name | Type | Description |
|---|---|---|
optionalJsonString | Collection.Optional(Text) | The JSON text to parse. |
Returns
Returns Collection.Optional(Location.Place) — the parsed place, or none.
Location.PositionClient.Request
Streams the device's live GPS position, updating as it moves.
Parameters
| Name | Type | Description |
|---|---|---|
optionalRefreshRateMs | Collection.Optional(Maths.Integer) | How often to refresh, in milliseconds (default 5000). |
optionalAccuracy | Collection.Optional(Maths.Integer) | Desired accuracy level (default 2). |
optionalDistanceFilterMeters | Collection.Optional(Maths.Real) | Minimum movement before an update, in metres (default 0). |
Returns
Returns Collection.Optional(Location.Coordinate) — the latest reading, or none until the device reports its first fix.
Example
STATE LOCKED Location.Coordinate here = Location.PositionClient.RequestLocation.ReverseLookup
Reverse-geocodes a coordinate into a place with an address, or none when nothing matches.
Parameters
| Name | Type | Description |
|---|---|---|
coordinate | Location.Coordinate | The point to reverse-geocode. |
Returns
Returns Collection.Optional(Location.Place) — the place at that point, or none.
Example
STATE LOCKED Location.Place place = Location.ReverseLookup hereLocation.Route.FromJson
Decodes a route from a JSON value.
Parameters
| Name | Type | Description |
|---|---|---|
optionalJson | Collection.Optional(Code.Language.Json.Value) | The JSON to decode. |
Returns
Returns Location.Route — the decoded route.
Location.Route.OptionalFromJson
Decodes an optional route from a JSON value, or none when absent.
Parameters
| Name | Type | Description |
|---|---|---|
optionalJson | Collection.Optional(Code.Language.Json.Value) | The JSON to decode. |
Returns
Returns Collection.Optional(Location.Route) — the decoded route, or none.
Location.Route.ToJson
Encodes a route as a JSON value.
Parameters
| Name | Type | Description |
|---|---|---|
route | Location.Route | The route to encode. |
Returns
Returns Code.Language.Json.Value — the route as a JSON object.
Location.Service.Client.Send
Emits the device's current coordinate into the LocationService streaming pipeline.
Parameters
| Name | Type | Description |
|---|---|---|
position | Location.Coordinate | The coordinate to publish. |
Returns
Returns nothing — it streams position to the location server over an open session.
Example
Location.Service.Client.Send hereLocation.ToJson
Encodes a place as a JSON value.
Parameters
| Name | Type | Description |
|---|---|---|
location | Location.Place | The place to encode. |
Returns
Returns Code.Language.Json.Value — the place as a JSON object.