> ## Documentation Index
> Fetch the complete documentation index at: https://docs.frogbot.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Point Field

> Store longitude and latitude coordinates and run supported geospatial queries.

**SQLite and D1 are unsupported.** Do not use Point fields with
`@frogbotai/db-sqlite` or `@frogbotai/db-d1-sqlite`. JSON storage does not
provide the spatial indexes or operators required by this field.

The Point field stores a coordinate pair in `[longitude, latitude]` order and creates the spatial index needed for location queries on supported database adapters.

```ts theme={"theme":"tokyo-night"}
import type { CollectionConfig } from 'frogbot'

export const Places: CollectionConfig = {
  slug: 'places',
  fields: [
    {
      name: 'location',
      type: 'point',
      required: true,
    },
  ],
}
```

## Config options

| Option | Type | Default | Description |
| - | - | - | - |
| `name` | `string` | Required | Property name used in stored records and APIs. See [field names](https://docs.frogbot.ai/fields/overview.md#field-names). |
| `type` | `'point'` | Required | Selects the Point field. |
| `label` | `string \| Record<string, string> \| (({ i18n, t }) => string) \| false` | Generated from `name` | Label shown in the admin panel. Use an object keyed by language code for translations, or `false` to hide the label. |
| `required` | `boolean` | `false` | Rejects an empty value in the default validation. |
| `unique` | `boolean` | `false` | Creates a unique database index for the field path. See [indexes](https://docs.frogbot.ai/database/indexes.md). |
| `index` | `boolean` | MongoDB: `true` | MongoDB creates a `2dsphere` index unless this is `false`. Postgres creates an index only when this is `true`. |
| `localized` | `boolean` | `false` | Stores one value per configured locale. Ignored without [localization](https://docs.frogbot.ai/configuration/localization.md) or inside a localized parent. |
| `defaultValue` | `[number, number]` or `({ locale, req, user }) => value` | — | Value used when the field has no value. See [default values](https://docs.frogbot.ai/fields/overview.md#default-values). |
| `validate` | `Validate` | Built-in validator | Replaces the built-in validator. See [validation](https://docs.frogbot.ai/fields/overview.md#validation). The built-in validator checks that both coordinates are numbers within range. |
| `hooks` | `{ beforeValidate, beforeChange, afterChange, afterRead, beforeDuplicate }` | — | Arrays of `FieldHook` functions for each phase. See [field hooks](https://docs.frogbot.ai/hooks/fields.md). |
| `access` | `{ create, read, update }` | Allowed | `FieldAccess` functions for each operation. See [field access control](https://docs.frogbot.ai/access-control/fields.md). |
| `hidden` | `boolean` | `false` | Removes the field from API responses and the admin panel while keeping stored data. |
| `saveToJWT` | `boolean \| string` | `false` | In an auth-enabled collection, copies the value into the user's token. A string sets the token key. See [token data](https://docs.frogbot.ai/authentication/token-data.md). |
| `virtual` | `boolean \| string` | `false` | `true` skips database storage; a string reads a value through a relationship path. Virtual fields are read-only in the admin panel unless `admin.readOnly` is `false`. See [virtual fields](https://docs.frogbot.ai/fields/overview.md#virtual-field-configuration). |
| `disableDuplicate` | `boolean` | `false` | Leaves the value out when a document is duplicated, so the copy uses `defaultValue`. |
| `admin` | `object` | — | Admin-panel options. See [Admin options](#admin-options). |
| `custom` | `Record<string, any>` | — | Server-only metadata for your own code and plugins. Use `admin.custom` for data the browser also needs. |
| `jsonSchema` | `Array<({ jsonSchema }) => JSONSchema4>` | — | Functions that modify the JSON Schema used by [type generation](https://docs.frogbot.ai/typescript/generating-types.md). |

## Admin options

Point fields support the standard [field admin options](https://docs.frogbot.ai/fields/overview.md#admin-options), plus these options:

| Option | Type | Default | Description |
| - | - | - | - |
| `placeholder` | `string \| Record<string, string>` | — | Placeholder text for both coordinate inputs. Use an object keyed by language code for translations. |
| `step` | `number` | — | Amount the browser controls add or subtract on both coordinate inputs. |

## Querying with near

`near` finds records by distance from a coordinate and sorts nearest first. Its value contains `[longitude, latitude, maximumDistance, minimumDistance]`; distances are in meters.

```ts theme={"theme":"tokyo-night"}
const nearby = await frogbot.find({
  collection: 'places',
  overrideAccess: true,
  where: {
    location: {
      near: [-73.9857, 40.7484, 5000, 0],
    },
  },
})
```

## Querying within

`within` finds points inside a GeoJSON area. A polygon's first and final coordinates must match.

```ts theme={"theme":"tokyo-night"}
const polygon: [number, number][] = [
  [-74.02, 40.7],
  [-74.02, 40.8],
  [-73.93, 40.8],
  [-73.93, 40.7],
  [-74.02, 40.7],
]

const places = await frogbot.find({
  collection: 'places',
  overrideAccess: true,
  where: {
    location: {
      within: {
        type: 'Polygon',
        coordinates: [polygon],
      },
    },
  },
})
```

## Querying intersects

`intersects` finds points that intersect a GeoJSON geometry.

```ts theme={"theme":"tokyo-night"}
const places = await frogbot.find({
  collection: 'places',
  overrideAccess: true,
  where: {
    location: {
      intersects: {
        type: 'Polygon',
        coordinates: [
          [
            [-74.02, 40.7],
            [-74.02, 40.8],
            [-73.93, 40.8],
            [-73.93, 40.7],
            [-74.02, 40.7],
          ],
        ],
      },
    },
  },
})
```

## Custom components

Override the field or its label through `admin.components`. Custom components can wrap FrogBot's default coordinate controls.

### Field

#### Server component

```tsx theme={"theme":"tokyo-night"}
import { PointField } from '@frogbotai/ui/admin'
import type { PointFieldServerProps } from 'frogbot'

export const CustomPointFieldServer = ({
  clientField,
  path,
  permissions,
  schemaPath,
}: PointFieldServerProps) => (
  <PointField
    field={clientField}
    path={path}
    permissions={permissions}
    schemaPath={schemaPath}
  />
)
```

#### Client component

```tsx theme={"theme":"tokyo-night"}
'use client'

import { PointField } from '@frogbotai/ui/admin'
import type { PointFieldClientProps } from 'frogbot'

export const CustomPointFieldClient = (props: PointFieldClientProps) => (
  <PointField {...props} />
)
```

### Label

#### Server component

```tsx theme={"theme":"tokyo-night"}
import { FieldLabel } from '@frogbotai/ui/admin'
import type { PointFieldLabelServerProps } from 'frogbot'

export const CustomPointLabelServer = ({
  clientField,
  path,
}: PointFieldLabelServerProps) => (
  <FieldLabel
    label={clientField.label || clientField.name}
    path={path}
    required={clientField.required}
  />
)
```

#### Client component

```tsx theme={"theme":"tokyo-night"}
'use client'

import { FieldLabel } from '@frogbotai/ui/admin'
import type { PointFieldLabelClientProps } from 'frogbot'

export const CustomPointLabelClient = ({ field, path }: PointFieldLabelClientProps) => (
  <FieldLabel label={field.label || field.name} path={path} required={field.required} />
)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.