gabrielesbaiz/nova-field-map

Leaflet map field for Laravel Nova 5 with GeoJSON, editable markers, drawing, clustering and dark mode.
16,284
Install
composer require gabrielesbaiz/nova-field-map
Latest Version:3.0.0
PHP:^8.2
License:MIT
Last Updated:Sep 28, 2026
Links: GitHub  ·  Packagist
Maintainer: gabrielesbaiz

NovaField Map

A Leaflet map field for Laravel Nova 5 — reads the coordinate column your model already has, draws it, and lets an administrator drop the pin themselves.

Latest version PHP Laravel Downloads Stars Sponsor

📖 Read the documentation →

Every one of the 58 methods with its signature, a playground where you build a field with controls and watch the chain, the preview and the serialized payload change together, plus recipes, tile providers and the upgrade path from 2.x.

[!CAUTION] Upgrading from 2.x? Read UPGRADE.md first. Three things changed that your resources will notice: popup content is now escaped by default (2.x rendered it as raw HTML, which was a stored-XSS hole), the field now resolves its own attribute instead of being handed data at make() time, and minimap(), measure(), exportImage() and popupActions() do not exist. Every other 2.x call still works.

[!IMPORTANT] Does this save you time? A ⭐ costs you nothing and helps other developers find it. Sponsoring keeps it compatible with every new Nova release.

What it does

If all you need is to show a latitude and a longitude, you do not need this package. Two Number fields do that with less JavaScript and less to go wrong, and an administrator who knows the coordinates can type them. This package exists for when the shape of the place is the information:

  • Reads the column you already have. A "45.6495,13.7768" string, a [lat, lng] array, a keyed array, GeoJSON or a spatial Point — detected, not declared.
  • An ordinary Nova field. It resolves its own attribute, so dependsOn(), resolveUsing(), filling and validation all work. 2.x could not do any of that.
  • Editable when you ask. Points, lines, polygons, rectangles and circles, with place search, address filling and an arrow-key nudge.
  • Dense data stays readable. Clustering, heatmaps, choropleth, category filters, a timeline and a canvas renderer past a thousand features.
  • Popups are escaped in PHP, and HTML is an explicit opt-in that is still sanitised in the browser.
  • Leaflet is not on every page. The entry bundle is 11 kB gzipped; the map itself arrives only when one is about to become visible.

The trade is size and honesty about it: a page that renders a map pays roughly 52 kB gzipped for Leaflet. If an index table needs a location column and nothing more, use snapshot() or two numbers rather than a live map per row.

Requirements

  • PHP 8.2 or newer
  • Laravel 11, 12 or 13
  • Laravel Nova 5 (sold separately)

Nova 4 is not supported. Use 2.x for Nova 4.

Installation

composer require gabrielesbaiz/nova-field-map

php artisan vendor:publish --tag=nova-field-map-config
php artisan vendor:publish --tag=nova-field-map-lang

php artisan nova-field-map:doctor

The service provider is auto-discovered and the assets ship built: no migrations, no nova:publish, nothing to compile. Both publish steps are optional — the defaults use OpenStreetMap tiles, which need no key.

Full installation guide →

Artisan commands

Command Purpose
nova-field-map:doctor Verifies the built assets exist, the configured keys are present, and every tile host responds. --skip-network skips the outbound requests.

See the commands page.

Documentation

Documentation site Everything: install, configure, operate.
Playground Build a field with controls; read the chain, the preview and the payload as they change.
API reference All 58 methods, searchable, with signatures.
Recipes Store locator, delivery zone, address form, GPS track.
Tile providers The ten built in, which need a key, and adding your own.
Troubleshooting Blank maps, missing tiles, popups showing as text.
Security The threat model and what escaping actually covers.
UPGRADE.md Upgrading from 2.x. Read before you start.
CHANGELOG.md What changed, and when.

Testing

composer test        # Pest
composer analyse     # PHPStan
composer format      # Pint

npm run test         # Vitest
npm run build        # Vite, both passes

There is no CI. Those commands are the contract, and between them they prove the parts that are easy to break: 2.x chains still serialize, popup content is escaped by default and sanitised when allowed, an empty collection never reaches fitBounds, exactly one layer control renders, two fields on one page keep their own marker icons, and map.remove() really runs on unmount.

Contributing

Pull requests and issues are welcome. Run the five commands above before opening one — a change that leaves any of them red will be asked for a fix first.

Security vulnerabilities

Please review our security policy for reporting a vulnerability. Please do not open a public issue.

Credits

Built on Leaflet, Leaflet.markercluster, Leaflet-Geoman and DOMPurify. Geocoding by Nominatim unless configured otherwise.

Support this package

I maintain this on evenings and weekends, alongside a full-time job writing insurance software. Keeping it green across new Nova majors is the unglamorous part, and it is what keeps this installable in your composer.json next year too.

If it is useful to you:

  • ⭐ Star the repo. Free, thirty seconds, and it is the first signal other developers look at.
  • ❤️ Become a sponsor. From $5 a month. Company tiers get your logo right here in this README.
  • 🐛 Open a good issue. A clear reproduction is worth more than you think.
  • 🗣️ Tell another Laravel developer. Word of mouth is how packages survive.

Sponsor on GitHub

Disclaimer

This package is provided as is. It renders geographic data supplied by your application and by third-party tile and geocoding providers; the accuracy of what appears on the map, and the licence terms of the tiles you choose to serve, are the deploying application's responsibility, not this package's.

License

MIT. See LICENSE.md. The MIT licence's warranty disclaimer and limitation of liability apply in full, alongside the section above.

Related Packages

traineratwot/filament-openstreetmap

OpenStreetMap field for Filament forms with Leaflet.js — pick coordinates, geoco...

2,102 28
salemaljebaly/filament-map-picker

A Leaflet / OpenStreetMap map picker field for Filament v5.

1,558 2
lbcdev/livewire-maps-core

A Livewire component for interactive maps using Leaflet

2 0
lbcdev/livewire-map-component

A Livewire component for interactive maps using Leaflet

157 1
lbcdev/filament-maps-fields

A Filament package providing map field components for forms and infolists using...

0 0