> ## Documentation Index
> Fetch the complete documentation index at: https://flex-fields.bjanczak.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Examples target Filament 5. Verify optional dependencies before configuring integrations.
> Upload transfer completion, permanent storage and record acceptance are separate milestones. Native and Spatie image conversions retain the original.

# MapEditorField

> Edit points, polylines, polygons, rectangles and circles in one validated GeoJSON collection.

<video autoPlay muted loop playsInline controls preload="metadata" src="https://mintcdn.com/flex-fields/cY70dYD2SDr8chb8/art/previews/map-editor-motion.mp4?fit=max&auto=format&n=cY70dYD2SDr8chb8&q=85&s=a10d0351dca1a6574740b37a1008eedb" poster="/art/previews/map-editor.webp" width="1920" height="1080" aria-label="MapEditorField — FLEX Fields demonstration">
  [Watch the MapEditorField demonstration (MP4).](https://flex-fields.bjanczak.com/art/previews/map-editor-motion.mp4)
</video>

`MapEditorField` combines points, lines and zones in one field. It enables mixed-feature mode automatically and starts with address search disabled. Use it for service plans, venue layouts or collections that need more than one geometry type.

## Basic usage

```php theme={"theme":{"light":"github-light","dark":"github-dark"}}
use Bjanczak\FilamentFlexFields\Filament\Forms\Components\MapEditorField;

MapEditorField::make('service_map')
    ->mapProvider('maplibre')
    ->allowedGeometryTypes(['Point', 'LineString', 'Polygon'])
    ->drawingTools(['point', 'polyline', 'polygon', 'rectangle', 'circle'])
    ->maxFeatures(40)
    ->maxLineVertices(64)
    ->maxZoneVertices(128)
    ->snapDistance(12)
    ->geometryStrokeWidth(2)
    ->zoneFillOpacity(.18)
    ->pointSize(18)
    ->featureTooltips()
    ->showZoneMetrics()
    ->drawingHistoryLimit(32)
    ->fullscreen();
```

Rendering, styles, camera limits and controls use the [shared map configuration](https://flex-fields.bjanczak.com/docs/location-v4.md). Add `searchable()` only when you also configure an address-search provider; search adds points rather than generating lines or zones.

## Tools and geometry restrictions

| Drawing tool | GeoJSON type |
| - | - |
| `point` | Point |
| `polyline` | LineString |
| `polygon`, `rectangle`, `circle` | Polygon |

`allowedGeometryTypes()` is enforced on the server and must agree with `drawingTools()`. For a point-and-line editor, configure both lists:

```php theme={"theme":{"light":"github-light","dark":"github-dark"}}
MapEditorField::make('inspection_path')
    ->mapProvider('maplibre')
    ->allowedGeometryTypes(['Point', 'LineString'])
    ->drawingTools(['point', 'polyline'])
    ->maxLineVertices(64);
```

Enter/Finish commits a polyline with at least two distinct adjacent vertices. Escape cancels a draft and Backspace removes its latest point. Polygon, rectangle and circle interactions follow the [zone editor](https://flex-fields.bjanczak.com/docs/map-zones.md#drawing-tools).

## Editing and history

Selected lines support dragging or keyboard movement of vertices, inserting segment midpoints, removing vertices down to two, whole-line movement and rotation. Polygon editing follows the same committed-operation history. Invalid completed geometry does not replace accepted form state.

`editableZones(false)` disables line/polygon vertex and property editing. Point dragging has its own `draggableMarkers()` policy. `deletableFeatures(false)` controls removal separately; disabled/read-only fields block edits.

Undo/redo spans geometry types and metadata with a bounded history budget. New edits after undo discard the redo branch. Use [feature forms and actions](https://flex-fields.bjanczak.com/docs/map-feature-forms.md) for custom geometry-specific modal forms and PHP callbacks.

## State and database storage

Use a JSON column with an Eloquent `array` cast. The value is a GeoJSON FeatureCollection containing the admitted Point, LineString and Polygon features. Each feature needs a unique stable ID. GeoJSON coordinate pairs use `[longitude, latitude]`.

Collection modes require structured storage. Supplied `mapFeatures()` overlays are separate from this editable state and are not automatically persisted with it.

## Limits and appearance

| Method | Accepted values |
| - | - |
| `maxFeatures()` | Up to 200 features; configure a smaller application limit. |
| `maxLineVertices()` | 2–512 vertices per line. |
| `maxZoneVertices()` | 3–511 distinct outer-ring vertices. |
| `geometryStrokeWidth()` | 0.5–12 pixels. |
| `zoneFillOpacity()` | 0–1. |
| `pointSize()` | 12–48 pixels for GPU points and the selected DOM circle. |
| `snapDistance()` | 0–40 screen pixels; zero disables snapping. |
| `featureTooltips(false)` | Hide hover/focus labels. |
| `showZoneMetrics(false)` | Hide zone metric labels. |

The geometry boundary also enforces a 10,000-total-vertex limit and validates submitted topology independently of the browser. Zone-specific area and overlap policies are described on [MapZonesField](https://flex-fields.bjanczak.com/docs/map-zones.md#validation-and-overlap-policies).

## Supported scope

Lines represent geometry supplied or drawn by your application; the field does not calculate routes. Mixed-feature mode is unclustered. Use [MapMarkersField](https://flex-fields.bjanczak.com/docs/map-markers.md) for clustered Point collections.

Polygon holes, polygon cutting/merging, freehand drawing, text annotations and continuous device GPS tracking are not implemented.


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