Download the PHP package siberfx/backpack-leaflet-drawjs without Composer
On this page you can find all versions of the php package siberfx/backpack-leaflet-drawjs. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download siberfx/backpack-leaflet-drawjs
More information about siberfx/backpack-leaflet-drawjs
Files in siberfx/backpack-leaflet-drawjs
Package backpack-leaflet-drawjs
Short Description Leaflet Draw polygon field (GeoJSON) for Laravel Backpack 7.x
License MIT
Homepage https://github.com/siberfx/backpack-leaflet-drawjs
Informations about the package backpack-leaflet-drawjs
Leaflet Draw field for Backpack
Draw polygons on a Leaflet map (Mapbox or OpenStreetMap) and store them as GeoJSON, as a Laravel Backpack 7.x CRUD field.
Features
- Draw, edit and delete polygons right inside a Backpack create / update form
- Saves the shape as a standard GeoJSON
Feature(or aFeatureCollectionin multiple mode) - Mapbox tiles, or OpenStreetMap with no API key needed
- Assets are loaded through Basset, so nothing has to be published
- Works with several map fields on one form, and inside tabs and modals
Requirements
| Package | Version |
|---|---|
| PHP | 8.2, 8.3, 8.4, 8.5 |
| Laravel | 12.x, 13.x |
| Backpack/CRUD | 7.x |
Using Backpack 6.x? Install the 1.x line:
composer require siberfx/backpack-leaflet-drawjs:^1.3
Installation
The service provider is auto-discovered, and the leaflet-draw field type works straight away.
Optionally add a Mapbox token to your .env. Without one, the field uses OpenStreetMap tiles:
Usage
1. Add a column that can hold JSON
2. Cast the attribute on your model
3. Add the field to your CrudController
That's all you need. Backpack saves the GeoJSON with the rest of the form, so you don't need a custom route or controller.
Field options
Every option is optional. Anything you leave out falls back to config/backpack/leaflet-draw.php.
Stored data
With multiple => false (the default), the field stores a single GeoJSON Feature:
With multiple => true, it stores a FeatureCollection. When every shape is deleted, the field stores an empty value.
Configuration
To change the defaults, publish the config file:
To customize the field markup, publish the view. It is copied to resources/views/vendor/backpack/crud/fields/leaflet-draw.blade.php:
Use --tag="all" to publish both.
Upgrading from 1.x
- You now need Backpack 7.x, Laravel 12 or 13, and PHP 8.2 or newer.
- You no longer need to publish the view. If you published it before, delete
resources/views/vendor/backpack/crud/fields/leaflet-draw.blade.phpto pick up the new version. - The config file is now optional. If you published one, the
mapbox.access_tokenkey works as before.
Testing
The PHP suite boots a real Backpack 7 app (Tabler theme) with Orchestra Testbench. It renders the create and edit pages and saves polygons through Backpack. The JavaScript suite runs the field script against real Leaflet and Leaflet.draw in jsdom.
GitHub Actions runs both suites on every push and pull request: PHP 8.2 to 8.5 on Laravel 12, and PHP 8.3 to 8.5 on Laravel 13.
Changelog
See CHANGELOG.md.
Security
If you find a security issue, please email [email protected] rather than opening a public issue.
Credits
License
MIT. See LICENSE.md.