Download the PHP package jamesil/nova-google-polygon without Composer
On this page you can find all versions of the php package jamesil/nova-google-polygon. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package nova-google-polygon
Nova Google Polygon Field
A Laravel Nova field for creating and editing polygons on Google Maps.
Features
- Interactive polygon drawing and editing on Google Maps
- Support for multiple polygon points
- Real-time coordinate updates
- Customizable map center and zoom
- Laravel model casting support
- Polygon containment checking utilities
Requirements
- PHP 8.1 or higher
- Laravel Nova 4.0 or 5.0
- Laravel 9.0 or higher
- Google Maps API key with Maps JavaScript API enabled
Version Compatibility
Laravel Nova | Laravel | PHP | Package Version |
---|---|---|---|
5.0 | 10.x - 11.x | 8.1+ | 1.x |
4.0 | 9.x - 11.x | 8.1+ | 1.x |
Installation
Install the package via Composer:
Configuration
-
Publish the configuration file (optional):
- Set up your Google Maps API key:
First, create a Google Cloud project and enable the Maps JavaScript API:
- Visit Google Cloud Console
- Create a new project or select an existing one
- Enable the Maps JavaScript API
- Create credentials to get your API key
- Add environment variables:
Add these variables to your .env
file:
Usage
Basic Field Usage
Add the field to your Nova resource:
Database Setup
The polygon data is stored as JSON. Create a JSON column in your migration:
Model Casting
Use the provided cast to automatically handle polygon data:
Working with Polygons
The package provides utility classes for working with polygon data:
Advanced Example
Here's a complete example of using the field with a taxi pickup zone system:
API Reference
Polygon Class Methods
contain(Point|array $point)
: Check if a point is inside the polygonpointOnVertex(Point|array $point)
: Check if a point is on a polygon vertexgetBoundingBox()
: Get the bounding box coordinatesgetMinLatitude()
,getMaxLatitude()
: Get latitude boundsgetMinLongitude()
,getMaxLongitude()
: Get longitude boundsgetPoints()
: Get all polygon pointssetPoints(array $points)
: Set polygon points
Point Class Methods
fromArray(array $input)
: Create a point from arraytoArray()
: Convert point to arraytoJson()
: Convert point to JSON
Testing
Run the test suite:
Credits
- James Embling
- Based on the original work by YieldStudio
License
The MIT License (MIT). Please see License File for more information.
All versions of nova-google-polygon with dependencies
laravel/nova Version ^4.0|^5.0
illuminate/support Version ^9.0|^10.0|^11.0
ext-bcmath Version *