elbgoods/nova-mapbox-shape-field

Show geo shape on a mapbox map with drawing capabilities

Installs: 5 873

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Language:Vue

2.0 2023-04-17 16:00 UTC

This package is auto-updated.

Last update: 2024-10-17 19:33:56 UTC


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

Detail View

License

This project is open-sourced software licensed under the MIT license.