jamesil/nova-google-polygon
A Laravel Nova field for drawing and editing polygons on Google Maps, storing polygon coordinates or GeoJSON in your models. Adds an interactive map input to Nova forms for location-based data.
Start by updating the package in the project that uses the Nova field:
composer update jamesil/nova-google-polygon
If you are on Laravel 9–11 and remain on the 1.x line, the corresponding patch is 1.2.1. On the 2.x line, use 2.1.1. There is no API change in this release, so existing field definitions and Polygon::contain() calls should continue to work.
Look first at:
Polygon::contain() for point-in-polygon checks.A good first use case is a Nova-managed “service area” or “delivery zone” polygon. Editors draw the polygon in Nova, the geometry is stored on the model, and application code uses Polygon::contain() to decide whether a customer/address coordinate falls inside that area.
Register the package’s polygon field in a Nova resource and treat the stored polygon as the source of truth for spatial rules:
public function fields(Request $request)
{
return [
// Use the exact field class from the package README.
GooglePolygon::make('Service Area', 'service_area')
->rules('required'),
];
}
Common day-to-day patterns:
Polygon::contain() calls across controllers.contain() now returns false for empty or degenerate polygons, but silently treating an invalid polygon as “no match” can hide data-entry mistakes.This release is especially relevant if you already depend on contain() in production. The corrected even-odd ray-casting implementation fixes wrong results when a point shares a longitude with a polygon vertex and removes the previous ValueError near the equator caused by scientific-notation strings reaching bccomp.
false instead of throwing. That is safer at runtime, but you should still validate polygon data before saving it in Nova.ext-bcmath is no longer required by this package. You can remove it from Docker images or CI setup if it was present only for this package. Keep it if another dependency needs it.composer update jamesil/nova-google-polygon and run your existing containment tests.1.x should take 1.2.1; 2.1.1 is the current 2.x patch. Do not force a major-line jump just to get this fix.How can I help you explore Laravel packages today?