TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/diegobas/filament-drawable-map/llms.txt
Use this file to discover all available pages before exploring further.
DrawableMap field embeds an interactive Google Maps canvas directly inside a Filament form, giving users a way to define geographic polygon zones by clicking on the map. Vertex coordinates are automatically serialised to JSON and stored as a json database column, making the field a self-contained solution for delivery-zone, coverage-area, and geo-fencing use cases.
Basic Usage
Interaction
The map supports a keyboard-driven drawing mode so that normal map panning and polygon editing never conflict with each other.Enter drawing mode
Hold the Ctrl key. The cursor changes to a crosshair and the polygon becomes editable.
Add a vertex
While holding Ctrl, click any point on the map to append a new vertex to the polygon. The polygon is drawn to the map automatically after the first vertex is placed.
Remove a vertex
While holding Ctrl, double-click an existing vertex to delete it from the polygon path.
Exit drawing mode
Release the Ctrl key. The cursor returns to the default pointer and the map resumes normal pan/zoom gesture handling.
Zoom to polygon
Click anywhere on the polygon (without holding Ctrl) to fit and pan the map to the polygon’s bounding box.
Method Reference
The field name that maps to the model attribute or Livewire state key. Must be unique within the form schema.
The human-readable label displayed above the map in the form layout.
Sets the initial map centre before any polygon exists. The array must contain exactly two keys:
latitude and longitude. Any extra keys are silently discarded.Defaults to ['latitude' => 0, 'longitude' => 0].The Google Maps zoom level used when the map first renders and no saved polygon is present. When a polygon already exists in state, the map auto-fits to its bounds instead.Default:
13.A hex colour string applied to both the polygon stroke and its semi-transparent fill. Accepts a plain string, an array, or a
Closure that returns a string.Default: '#FF0000'.Overrides the map colour scheme. Accepted values are
'light' and 'dark'. When not called, the component reads the --default-theme-mode CSS custom property and falls back to localStorage.theme, so it normally tracks the active Filament theme automatically.The text label of the Clear button rendered at the top-centre of the map.Default:
'Clear'.When
true, all map interaction — Ctrl+click drawing, vertex removal, polygon clicks, and the Clear button — is suppressed. The map is still rendered and the existing polygon is still displayed. Accepts a Closure for conditional disabling.getMode(), getState(), callAfterStateHydrated(), and getStateToDehydrate() are internal lifecycle methods used by the Filament framework during form hydration and dehydration. You do not call these directly in your form schema.State Format
The field stores and returns polygon coordinates as a JSON array of objects, each with alat and lng key. Internally the component encodes/decodes this automatically on hydration and dehydration, so your model only ever sees a PHP array or a JSON string.
json:
Disabled State
Pass a boolean or aClosure to disabled() to make the field read-only at runtime.
gestureHandling is set to 'none' and clickable icons are turned off at the Google Maps SDK level, so the map tile still loads but accepts no input.
The map canvas is fixed at 400 px tall by the component’s built-in inline style. This height cannot be changed through the PHP API — override it in your application’s stylesheet if a different height is required.