Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Nova Google Polygon Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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:

  1. The package README for the exact Nova field class and configuration options.
  2. The Nova resource where the polygon field is registered.
  3. Any application code calling 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.

Implementation Patterns

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:

  • Keep polygon editing in Nova, but centralize containment checks in an application service or action rather than scattering Polygon::contain() calls across controllers.
  • Validate that editors save at least three vertices before relying on the polygon for business rules. contain() now returns false for empty or degenerate polygons, but silently treating an invalid polygon as “no match” can hide data-entry mistakes.
  • Use containment checks for eligibility, routing, pricing zones, geofencing, or territory assignment.
  • Add feature tests around real boundary cases: points on vertices, points on minimum-latitude/minimum-longitude edges, equator coordinates, prime-meridian coordinates, and empty polygons.
  • If you expose containment through an API, return a clear “outside” or “invalid polygon” response rather than conflating degenerate geometry with a legitimate negative match.

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.

Gotchas and Tips

  • Boundary semantics matter. Points on a vertex are considered inside. Edges follow a documented half-open convention: minimum-latitude and minimum-longitude edges are inclusive. Write tests against those rules if boundary behavior affects billing, eligibility, or routing.
  • Invalid polygons now fail closed. Empty or fewer-than-three-vertex polygons return 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.
  • No API change means no refactor is required. Upgrade with composer update jamesil/nova-google-polygon and run your existing containment tests.
  • Watch the Laravel/Nova version line. Laravel 9–11 users on 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.
  • Coordinate conventions are still a common source of bugs. Confirm whether your stored polygons and queried points use the same latitude/longitude order expected by the package.
  • Debug containment with exact fixtures. When a point is unexpectedly inside/outside, test against a tiny polygon with known vertices, then test the same point on a vertex and on a min-latitude/min-longitude edge.
  • Extension point: keep custom map behavior and validation in your Nova field configuration or a small application-level wrapper. Because this release is a patch, avoid forking the package just for the containment fix; upgrade instead.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels