PHP code example of elbgoods / nova-mapbox-shape-field

1. Go to this page and download the library: Download elbgoods/nova-mapbox-shape-field library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

elbgoods / nova-mapbox-shape-field example snippets




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 [];
    }