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

Types

Location.Address

A postal address: a display line together with optional structured parts.

Fields

FieldTypeDescription
stringTextThe address as a single display line.
optionalStreetNumberCollection.Optional(Text)Street number, if known.
optionalStreetNameCollection.Optional(Text)Street name, if known.
optionalLocalityCollection.Optional(Text)Town or city, if known.
optionalAdministrativeAreaLevel1Collection.Optional(Text)Top-level region such as a state, if known.
optionalAdministrativeAreaLevel2Collection.Optional(Text)Second-level region such as a county, if known.
optionalCountryCollection.Optional(Text)Country, if known.
optionalPostalCodeCollection.Optional(Text)Postal or ZIP code, if known.
optionalFormattedAddressCollection.Optional(Text)Provider-formatted full address, if known.

Location.Coordinate

A geographic point as a latitude and longitude in degrees.

Fields

FieldTypeDescription
latitudeMaths.RealDegrees north of the equator.
longitudeMaths.RealDegrees east of the prime meridian.

Example

LET Location.Coordinate london = Location.Coordinate 51.5074 -0.1278
A coordinate for central London.

Location.Marker

A pin on a map: a coordinate with an optional title, text, and draggability.

Fields

FieldTypeDescription
coordinateLocation.CoordinateWhere the marker sits.
optionalTitleCollection.Optional(Text)Title shown for the marker, if any.
optionalTextCollection.Optional(Text)Description shown for the marker, if any.
optionalDraggableCollection.Optional(Logic.Maybe)Whether the marker can be dragged, if specified.

Location.Place

A resolved place: a coordinate together with an optional address.

Fields

FieldTypeDescription
coordinateLocation.CoordinateWhere the place is.
optionalAddressCollection.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

FieldTypeDescription
startLocation.PlaceWhere the route begins.
endLocation.PlaceWhere the route ends.
optionalWaypointsCollection.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

NameTypeDescription
optionalJsonCollection.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

NameTypeDescription
optionalJsonCollection.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

NameTypeDescription
addressLocation.AddressThe 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

NameTypeDescription
optionalAddressCollection.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

NameTypeDescription
queryTextThe 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

NameTypeDescription
queryTextThe 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

NameTypeDescription
latitudeMaths.RealDegrees north of the equator.
longitudeMaths.RealDegrees 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

NameTypeDescription
optionalJsonCollection.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

NameTypeDescription
coordinateLocation.CoordinateThe 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

NameTypeDescription
optionalJsonCollection.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

NameTypeDescription
addressStringTextThe 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"
Geocodes an address, pending until the lookup returns.

Location.MapMarker.Fixed

Places a non-draggable marker on the map at a fixed coordinate.

Parameters

NameTypeDescription
coordinateLocation.CoordinateWhere 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"
A titled pin fixed at the London coordinate.

Location.MapMarker.Interactive

Places a draggable marker whose coordinate is bound two-way to a cell.

Parameters

NameTypeDescription
coordinateLocation.CoordinateThe 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"
A draggable pin that writes its new position back to pin.

Location.MapMarker.Text

Sets the description text on the enclosing marker.

Parameters

NameTypeDescription
textTextThe 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

NameTypeDescription
textTextThe 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

NameTypeDescription
startCoordinateLocation.CoordinateWhere the line begins.
endCoordinateLocation.CoordinateWhere the line ends.

Returns

Returns nothing — it draws a line on the enclosing map.

Example

Location.MapRoute.Line home office
Connects two coordinates with a straight line.

Location.OptionalFromJsonString

Parses a place from a JSON string, or none when the string is absent.

Parameters

NameTypeDescription
optionalJsonStringCollection.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

NameTypeDescription
optionalRefreshRateMsCollection.Optional(Maths.Integer)How often to refresh, in milliseconds (default 5000).
optionalAccuracyCollection.Optional(Maths.Integer)Desired accuracy level (default 2).
optionalDistanceFilterMetersCollection.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.Request
A live position cell, pending until the device reports its location.

Location.ReverseLookup

Reverse-geocodes a coordinate into a place with an address, or none when nothing matches.

Parameters

NameTypeDescription
coordinateLocation.CoordinateThe 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 here
Reverse-geocodes a coordinate, pending until the address arrives.

Location.Route.FromJson

Decodes a route from a JSON value.

Parameters

NameTypeDescription
optionalJsonCollection.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

NameTypeDescription
optionalJsonCollection.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

NameTypeDescription
routeLocation.RouteThe 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

NameTypeDescription
positionLocation.CoordinateThe coordinate to publish.

Returns

Returns nothing — it streams position to the location server over an open session.

Example

Location.Service.Client.Send here
Publishes the live position to the location service.

Location.ToJson

Encodes a place as a JSON value.

Parameters

NameTypeDescription
locationLocation.PlaceThe place to encode.

Returns

Returns Code.Language.Json.Value — the place as a JSON object.