1. Go to this page and download the library: Download jamesil/nova-google-polygon 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/ */
jamesil / nova-google-polygon example snippets
use Jamesil\NovaGooglePolygon\GooglePolygon;
public function fields(Request $request)
{
return [
ID::make()->sortable(),
Text::make('Name'),
GooglePolygon::make('Coverage Area', 'coverage_area'),
];
}
Schema::create('locations', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->json('coverage_area')->nullable();
$table->timestamps();
});
use Jamesil\NovaGooglePolygon\Casts\AsPolygon;
class Location extends Model
{
protected $casts = [
'coverage_area' => AsPolygon::class,
];
}
use Jamesil\NovaGooglePolygon\Support\Point;
$location = Location::find(1);
// Is a coordinate inside the zone?
$location->coverage_area->contain(new Point(48.8585, 2.3370)); // true / false
// Bounds
$location->coverage_area->getBoundingBox();
$location->coverage_area->getMinLatitude();
$location->coverage_area->getMaxLatitude();