elbgoods / nova-mapbox-shape-field
Show geo shape on a mapbox map with drawing capabilities
2.0
2023-04-17 16:00 UTC
Requires
- php: ^8.0
- ext-json: *
- laravel/nova: ^4.1
README
Requirements
php: >=8.0
laravel/nova: ^4.1
Features
- Shows a geo shape with drawing capabilities
Installation
Install the package in a Laravel Nova project via Composer:
composer require elbgoods/nova-mapbox-shape-field
Usage
Expects a mapbox access-token specified in config/services.php
:
<?php return [ 'mapbox' => [ 'key' => env('MAPBOX_KEY', 'your-default-key'), ],
use Elbgoods\NovaMapboxShapeField\MapboxShapeField; public function fields(Request $request) { return [ MapboxShapeField::make('Geometry') // Postgres Geometry Column ->latitude($this->latitude) ->longitude($this->longitude) ->geoJson($this->getGeoJson()) ->zoom(8), ]; }
public function getGeoJson(): array { if ($this->geometry) { $geometry = $this->getGeometry(); // Brick\Geo\Geometry return [ 'type' => $geometry->geometryType(), 'coordinates' => $geometry->toArray(), ]; } return []; }
Screenshot
License
This project is open-sourced software licensed under the MIT license.