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.
ViewableMap field renders a non-editable Google Maps canvas that displays one or more pre-existing polygon zones. It is designed for detail pages, infolist panels, or any form context where users need to inspect geographic areas without being able to modify them. Polygons support individual colours, hover tooltips, and click-to-zoom behaviour out of the box.
Basic Usage
Display a single polygon stored in a model attribute:zone. The value must be a JSON string or a PHP array of lat/lng coordinate objects — the same format produced by DrawableMap.
Displaying Multiple Polygons
Usepolygons() to supply an explicit array of polygon coordinate sets and titles() to attach a hover tooltip to each one.
color(). The initial map centre is taken from the package’s published config (filament-drawable-map.location.latitude / filament-drawable-map.location.longitude) — ViewableMap does not expose a location() setter.
Method Reference
The field name. In single-polygon mode this must match the model attribute that holds the coordinate JSON. In multi-polygon mode (when
polygons() is provided) the name is still required by Filament’s field system but the field’s own state value is ignored.An explicit array of polygon coordinate sets to display. Each element is itself an array of coordinate objects in the form
[['lat' => ..., 'lng' => ...], ...]. Accepts a Closure that receives the current $record.When polygons() is not called, the component falls back to reading its own Livewire-entangled state value (the single model attribute).An array of tooltip strings, one per polygon, shown as a floating popup bubble when the user hovers over that polygon. The order must match the order of entries in
polygons().A hex colour string applied to the polygon stroke and semi-transparent fill. In multi-polygon mode this serves as the fallback colour for any polygon whose index has no entry in the resolved colours array.Default:
'#FF0000'.Overrides the map colour scheme. Accepted values are
'light' and 'dark'. When not set, the component checks localStorage.theme and the browser’s prefers-color-scheme media query, so it tracks the active Filament theme automatically without any configuration.When
true, gesture handling is set to 'none' and map icon clicks are disabled at the Google Maps SDK level. The polygons remain visible but the map cannot be panned or zoomed by the user.getTitles(), getColor(), getMode(), getPolygons(), getState(), and callAfterStateHydrated() are internal lifecycle and accessor methods used by the Filament framework and the Blade template. You do not call these directly in your form schema.Interaction
ViewableMap is read-only but still provides several passive interactions to help users navigate between zones.
Hover tooltip
Move the pointer over any polygon to show a floating bubble containing its title. The bubble disappears when the pointer leaves the polygon.
Click to zoom
Click a polygon to fit and pan the map to that polygon’s bounding box.
Auto-fit on load
On initialisation the map automatically calculates a global bounding box across all polygons and fits the viewport to show all of them at once.
Dark mode sync
The component listens for the
dark-mode-toggled window event dispatched by Filament and switches between the light and dark Google Maps colour scheme without a page reload.State Format
In single-polygon mode the field reads its value from the model attribute. The stored value must be a JSON string or PHP array of coordinate objects:json database column is all that is needed:
When
polygons() is provided, the field’s own state value (the model attribute bound to make()) is completely ignored. All coordinate data is taken exclusively from the array returned by your polygons() closure. You can therefore pass any field name to make() — it only serves as a unique identifier within the Filament form schema.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.