swisnl / filament-geometry
Geometry form field for Filament PHP
Fund package maintenance!
swisnl
Requires
- php: ^8.1
- filament/filament: ^3.0
- filament/forms: ^3.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.1
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2025-07-02 12:52:54 UTC
README
Warning
Work in progress, not stable yet!
Installation
You can install the package via composer:
composer require swisnl/filament-geometry
You can publish the views using
php artisan vendor:publish --tag="filament-geometry-views"
Component
Geometry Field
The Geometry field displays a leaflet map, with a set of configuration options.
Usage
Geometry Field
Note: The Geometry field expects the value to be a valid GeoJSON string. Make sure your model attribute stores and retrieves GeoJSON data as a string.
The form field can be used with no options, by simply adding this to your Filament Form schema:
use Swis\Filament\Geometry\Enums\DrawMode; use Swis\Filament\Geometry\Forms\Geometry; ... ->schema[ ... Geometry::make('location') ->drawModes([ DrawMode::Marker, DrawMode::Polygon, DrawMode::Polyline, DrawMode::Rectangle, ]), ... ]
The name used for make() must be the one you set up as your model's computed geojson property. Note that you can have multiple maps on a form, by adding a second computed property referencing a second pair of geojson fields.
Full options
The full set of options is as follows. All option methods support closures, as well as direct values.
use Swis\Filament\Geometry\Enums\DrawMode; use Swis\Filament\Geometry\Forms\Geometry; ... Geometry::make('location') ->label(__('Location')) // Basic configuration ->detectRetina(true) ->maxZoom(28) ->minZoom(0) ->tilesUrl('https://tile.openstreetmap.org/{z}/{x}/{y}.png') ->zoom(15) // Marker configuration ->markerColor("#3b82f6") // Controls ->showFullscreenControl(true) ->showZoomControl(true) ->drawModes([ DrawMode::Marker, DrawMode::Polygon, DrawMode::Polyline, DrawMode::Rectangle, ]) // Location features ->boundaries(true, 49.5, -11, 61, 2) // Example for British Isles // GeoMan Integration ->geoManPosition('topleft')
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
SWIS ❤️ Open Source
SWIS is a web agency from Leiden, the Netherlands. We love working with open source software.