Maps plugin screenshot
Dark mode ready
Multilingual support
Supports v5.x

Maps by Rafał Strachowski

Community

Adds a location picker with address search, GeoJSON shape drawing, a table column and infolist entries that keep working in tabs, modals, repeaters and SPA mode, using OpenStreetMap without an API key.

Tags: Form Field Table Column Infolist Entry
Supported versions:
5.x 4.x
Rafał Strachowski avatar Author: Rafał Strachowski

Package health

Automated checks of this plugin's Composer package

73 / 100
Security 52
Maintenance 100
Ecosystem 100
15 checks
Third-party plugin. This is built by the community, not the Filament team. Filament does not review, endorse, or vet the security of plugins outside the filament/ namespace. Review the source and install at your own risk. Found malware or an unresolved security issue the author won't address? Report it .
Powered by Plumb Last scanned 5 days ago

Documentation

Filament Maps

Map fields for Filament 4 and 5 that keep working where map plugins usually break: hidden tabs, collapsed sections, repeaters, modals, slide-overs and SPA mode.

  • MapPicker: click the map, drag the marker or type the coordinates.
  • LocationPicker: the same plus address search, the address of the picked point written to a field, and "use my location".
  • GeoJsonPicker: draw, edit and remove polygons, rectangles, lines and markers, saved as GeoJSON.
  • MapColumn, MapEntry, GeoJsonEntry: map previews in tables and on view pages.

Leaflet with OpenStreetMap. No API key, no build step: the package ships prebuilt assets, and each map component loads only on pages that use it. Free and open source (MIT).

Map picker in a tab: click and drag the marker

#Requirements

  • PHP 8.2+
  • Filament 4.16+ or 5.11+

#Installation

composer require certles/filament-maps
php artisan filament:assets

Optionally publish the config file:

php artisan vendor:publish --tag=filament-maps-config

#Pick a point

#One JSON column

// migration
$table->json('location')->nullable();

// model
protected function casts(): array
{
    return ['location' => 'array'];
}

// form
use Certles\FilamentMaps\Forms\Components\MapPicker;

MapPicker::make('location');

The state is ['lat' => 52.2297, 'lng' => 21.0122] or null. An empty field is saved as null, never as 0,0.

#Separate latitude and longitude columns

MapPicker::make('location_picker')
    ->latitudeField('latitude')
    ->longitudeField('longitude'),

TextInput::make('latitude')->numeric(),
TextInput::make('longitude')->numeric(),

The picker reads both fields, writes the picked point back to them and is not saved itself. The two fields can also be Hidden.

#Options

MapPicker::make('location')
    ->defaultCenter(50.0617, 19.9373)   // used when there is no point yet
    ->defaultZoom(12)
    ->mapHeight(400)                    // px, or any CSS length: '24rem'
    ->draggable(false)                  // marker cannot be dragged
    ->clickToPlace(false)               // clicking the map does not move the marker
    ->coordinateInputs(false)           // hide the latitude/longitude inputs
    ->tiles('https://{s}.tile.example.com/{z}/{x}/{y}.png', '© Example', 18);

Use ->live() when other fields need to react to the point immediately.

#Search for an address

Address search fills the point and the address field

use Certles\FilamentMaps\Forms\Components\LocationPicker;

LocationPicker::make('location')
    ->addressField('address'),   // optional: fills this field with the address

TextInput::make('address'),

Choosing a search result moves the marker and fills the address. Clicking the map or dragging the marker looks up the address of the new point. All MapPicker options work too.

LocationPicker::make('location')
    ->searchable(false)    // no search box
    ->locateUser(false);   // no "use my location" button (it needs HTTPS)

#Draw shapes

Drawing a service area

// migration: $table->json('service_area')->nullable();
// model:     'service_area' => 'array' in casts()

use Certles\FilamentMaps\Forms\Components\GeoJsonPicker;

GeoJsonPicker::make('service_area')
    ->shapes(['polygon', 'rectangle'])   // any of: marker, polyline, polygon, rectangle
    ->maxShapes(1)                       // with 1, a new shape replaces the old one
    ->searchable(),                      // search box to find the area first

The state is a GeoJSON FeatureCollection with coordinates rounded to 7 decimals, or null. Invalid GeoJSON and too many shapes fail validation. Rectangles are saved as polygons.

#Tables and view pages

Map picker in a modal action, map preview in the table

use Certles\FilamentMaps\Infolists\Components\GeoJsonEntry;
use Certles\FilamentMaps\Infolists\Components\MapEntry;
use Certles\FilamentMaps\Tables\Columns\MapColumn;

MapColumn::make('location')->mapWidth(200)->mapHeight(120),

MapEntry::make('location'),

// from separate columns
MapEntry::make('position')
    ->state(fn ($record) => ['lat' => $record->latitude, 'lng' => $record->longitude]),

GeoJsonEntry::make('service_area'),

#Geocoding

Address search runs on your server: provider API keys never reach the browser, results are cached and each user is rate limited (30 requests per minute by default). The default provider is Photon with OpenStreetMap data and no key.

The public Photon instance is meant for fair use. For heavier use, self-host Photon and set FILAMENT_MAPS_PHOTON_URL. The public instance labels results in English, German or French. Other app locales get local names (for example "Kraków", "Warszawa").

To use another provider, implement Certles\FilamentMaps\Geocoding\Geocoder and bind it:

use Certles\FilamentMaps\Geocoding\CachedGeocoder;
use Certles\FilamentMaps\Geocoding\Geocoder;

$this->app->singleton(Geocoder::class, fn () => new CachedGeocoder(new MyGeocoder(/* ... */), cache()->store()));

In tests, bind Certles\FilamentMaps\Geocoding\FakeGeocoder with a list of GeocodingResult objects. It never calls the network.

#Tiles

OpenStreetMap's public tiles are fine for an admin panel with a handful of users. Read the tile usage policy and switch to a tile provider (tiles() or the config file) for heavier use.

#How it stays reliable

  • A map is created only when its container becomes visible (IntersectionObserver), so maps in hidden tabs, collapsed sections and modals start with the right size.
  • Every size change (tab switch, modal animation, sidebar collapse) calls Leaflet's invalidateSize() and re-centres the map if it was never visible.
  • The map element is ignored by Livewire morphing and is replaced only when its configuration or record changes.
  • Components clean up on destroy, so SPA navigation and removed repeater items do not leak map instances.
  • Mouse-wheel zoom turns on only after you click the map, so scrolling the page never gets stuck on it.
  • The package never sets window.L, so it does not clash with other Leaflet code on the page.

#Testing

composer test   # Pest; CI runs PHP 8.2–8.5 with Filament 4 and 5

tests/e2e/smoke.mjs and tests/e2e/geo-smoke.mjs run Playwright checks against a sandbox app: tabs, a collapsed section with a repeater, a modal, infolists, SPA navigation, address search, drawing and console errors.

#License

MIT. See LICENSE.md.

The author

Rafał Strachowski avatar Author: Rafał Strachowski

I'm a PHP developer from Poland working with Symfony, Laravel and WordPress. I build open-source tools that put real data where people need it: Filament Maps for Filament panels, and WordPress plugins that show Home Assistant and solar production data.

Plugins
1