PHP code example of opscale-co / nova-geospatial-fields

1. Go to this page and download the library: Download opscale-co/nova-geospatial-fields 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/ */

    

opscale-co / nova-geospatial-fields example snippets


Schema::create('places', function (Blueprint $table) {
    $table->id();
    $table->string('name');
    $table->json('location')->nullable();   // Location field
    $table->json('address')->nullable();    // Address field
    $table->json('geofence')->nullable();   // Geofence field
    $table->json('area')->nullable();       // Area field
    $table->json('route')->nullable();      // Route field
    $table->timestamps();
});

use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Resource;
use Opscale\Fields\Geospatial\Address;
use Opscale\Fields\Geospatial\Area;
use Opscale\Fields\Geospatial\Geofence;
use Opscale\Fields\Geospatial\Location;
use Opscale\Fields\Geospatial\Route;

class Place extends Resource
{
    public static $model = \App\Models\Place::class;

    public function fields(NovaRequest $request): array
    {
        return [
            ID::make()->sortable(),
            Text::make('Name')->rules('

// config/nova-geospatial-fields.php (publishable)
return [
    'tile_layer' => [
        'url' => 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
        'attribution' => '© OpenStreetMap contributors',
    ],
    'geocoder' => [
        'driver' => env('NOVA_GEOSPATIAL_GEOCODER', 'nominatim'),
        'nominatim' => [
            'url' => 'https://nominatim.openstreetmap.org',
            'user_agent' => env('APP_NAME', 'Laravel').' / nova-geospatial-fields',
        ],
        'photon' => [
            'url' => 'https://photon.komoot.io',
        ],
    ],
    'routing' => [
        'osrm_url' => 'https://router.project-osrm.org/route/v1',
    ],
];