Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions content/docs/fields/location.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ const officeLocation: LocationFieldMetadata = {
```

The coordinates themselves are the field's **value**, not metadata: the widget stores
an object carrying a `latitude` and a `longitude` and displays it as a comma-separated
pair. No exported type declares that value shape today, which is tracked as
[objectui#6154](https://github.com/objectstack-ai/objectui/issues/6154).
an object carrying a `lat` and an `lng` and displays it as a comma-separated pair.
That value shape is exported as `LocationValue` by `@objectstack/spec/data` —
`{ lat, lng, altitude?, accuracy? }` — and it is what
`valueSchemaFor({ type: 'location' })` validates a stored location against.

The value being edited, and the `className` / `disabled` a host supplies, are **not**
metadata keys — they are runtime widget props. See [Field Widget Props](/docs/fields/widget-props).
Expand All @@ -50,18 +51,25 @@ The location field stores coordinates as an object:

```plaintext
{
latitude: 37.7749,
longitude: -122.4194
lat: 37.7749,
lng: -122.4194
}
```

Input format: `latitude, longitude`
`altitude` and `accuracy` are optional numbers on the same object.

**Note**: the stored keys are `lat` and `lng`. The older `{ latitude, longitude }`
spelling is deprecated and is **rejected** by `valueSchemaFor({ type: 'location' })`
with `invalid_type` at `[lat]` and `[lng]` — do not author it.

Input format: `latitude, longitude` — a user still types a comma-separated
latitude-then-longitude pair; only the stored key names are `lat` / `lng`.
- Example: `37.7749, -122.4194`

## Coordinate Ranges

- **Latitude**: -90 to 90 (negative = South, positive = North)
- **Longitude**: -180 to 180 (negative = West, positive = East)
- **Latitude** (`lat`): -90 to 90 (negative = South, positive = North)
- **Longitude** (`lng`): -180 to 180 (negative = West, positive = East)

Examples:
- New York: `40.7128, -74.0060`
Expand Down Expand Up @@ -113,7 +121,7 @@ the renderer:
"type": "object-map", // the registered type name — there is no `plugin:map`
"objectName": "store", // the records to plot
"map": { // the declared config input; markers are derived from the data
"locationField": "location", // this page's field, read as { latitude, longitude }
"locationField": "location", // this page's field, read as { lat, lng }
"titleField": "name", // field used as the marker label
"zoom": 12, // initial zoom level
// Initial centre as [latitude, longitude]. Used only when no record
Expand All @@ -131,11 +139,11 @@ The field validates coordinate ranges:

```plaintext
// Valid coordinates
{ latitude: 37.7749, longitude: -122.4194 } ✓
{ lat: 37.7749, lng: -122.4194 } ✓

// Invalid - latitude out of range
{ latitude: 95, longitude: -122.4194 } ✗
{ lat: 95, lng: -122.4194 } ✗

// Invalid - longitude out of range
{ latitude: 37.7749, longitude: 200 } ✗
{ lat: 37.7749, lng: 200 } ✗
```