Skip to main content

Documentation 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.

After publishing the configuration file, you can set global defaults that apply to every map field across your Filament application. These defaults are used as the fallback values when no per-field overrides are provided, letting you centralise your map setup in one place rather than repeating coordinates or credentials on every field definition.

Publishing the config

Run the following Artisan command to copy the package configuration file into your application’s config/ directory:
php artisan vendor:publish --tag="filament-drawable-map-config"
This creates config/filament-drawable-map.php with the following contents:
// config/filament-drawable-map.php
return [
    'providers' => [
        'google' => [
            'key' => env('GOOGLE_MAPS_API_KEY', null),
        ],
    ],
    'location' => [
        'latitude'  => 39.500676,
        'longitude' => -0.439357,
    ],
];

Config key reference

providers.google.key
string|null
default:"null"
Your Google Maps JavaScript API key, read from the GOOGLE_MAPS_API_KEY environment variable by default. The ViewableMap Blade template reads this config value directly via config('filament-drawable-map.providers.google.key') when constructing the Google Maps script URL. The DrawableMap Alpine component receives the key through window.filamentData.api.key, which the service provider populates by calling FilamentAsset::registerScriptData() with env('GOOGLE_MAPS_API_KEY') directly. Set this to null (or leave the env var unset) to disable map rendering.
location.latitude
float
default:"39.500676"
The default map center latitude in decimal degrees. This value is used by ViewableMap as the initial map center when the field is rendered. When one or more polygons are present, the map automatically fits and pans to their combined bounds instead of using this fallback.
location.longitude
float
default:"-0.439357"
The default map center longitude in decimal degrees. Works in tandem with location.latitude as the fallback center point for ViewableMap fields. When polygons are present, the map auto-fits to their bounds and this value is not used.

Per-field overrides

The global location defaults can be overridden on individual DrawableMap fields using the fluent ->location() and ->zoom() methods provided by the InteractsWithMap trait.
use DiegoBas\FilamentDrawableMap\Forms\Components\DrawableMap;

DrawableMap::make('delivery_zone')
    ->location([
        'latitude'  => 40.712776,
        'longitude' => -74.005974,
    ])
    ->zoom(12)
    ->label('Delivery Zone'),
ViewableMap reads the center coordinates directly from the published config and does not expose a ->location() override. Instead, it automatically fits the viewport to the bounds of all rendered polygons whenever polygon data is available, so an explicit center is rarely needed.
Per-field ->location() and ->zoom() calls on DrawableMap always take precedence over the global config defaults. The global values in config/filament-drawable-map.php only apply when no per-field override is provided.

Build docs developers (and LLMs) love