Prerequisites
Google Maps API Key
Set your Google Maps API key in the environment file:config/forms.php:
Geospatial Package (Optional)
For Point and Polygon model casting, install the recommended package:matanyadaev/laravel-eloquent-spatial Point and Polygon objects.
Basic Usage
Coordinate Selection
With Model Binding
Component Attributes
Core Attributes
The input field name
Label text displayed above the map
Model instance for automatic value binding
Field Names
Name attribute for the latitude input field
Name attribute for the longitude input field
Name attribute for the radius input field
Name attribute for the polygon boundary field
Feature Flags
Enable latitude/longitude marker selection
Enable radius circle drawing (delivery zones, etc.)
Enable polygon boundary drawing
Hide coordinate/radius/polygon input fields (uses hidden inputs)
Disable map interaction and input fields
Values
Initial latitude value
Initial longitude value
Initial radius value
Initial polygon WKT string
Default Values
Default latitude when no value exists
Default longitude when no value exists
Default radius when no value exists
Default polygon WKT when no value exists
Map Center
Map center latitude (falls back to
get_setting('default_lat'))Map center longitude (falls back to
get_setting('default_lng'))Radius Configuration
Number of decimal places for radius input
Maximum allowed radius (Earth’s radius in meters)
Unit display for radius (
m for meters, km for kilometers)Layout Attributes
Display validation errors
Show or hide the label
Mark field as required
Display label and input inline
Additional CSS classes for inline label
Additional CSS classes for inline input wrapper
Enable JavaScript validation error display
CSS framework override (bootstrap-5, material-admin-26)
Examples
Simple Location Picker
Delivery Zone with Radius
Polygon Boundary
Hidden Inputs Mode
Read-Only Map Display
Custom Map Center
Eloquent Spatial Integration
The component automatically handles Point and Polygon objects from the eloquent-spatial package.Point Casting
Polygon Casting
Google Maps Integration
The component automatically loads the Google Maps JavaScript API when rendered:config/forms.php (scripts_stack).
Map Features
Search Functionality
The map includes a built-in search box for location lookup:Data Attributes
The map container uses these data attributes for JavaScript initialization:data-map-selector="true"- Identifies the map containerdata-lat- Initial center latitudedata-lng- Initial center longitudedata-enable-marker- Enable coordinate markerdata-disabled- Disable map interactiondata-enable-radius- Enable radius circledata-enable-polygon- Enable polygon drawing
CSS Classes
Key CSS classes for styling:.map-selector-map- Map container element.map-selector-search- Search input element.map-selector-lat- Latitude input element.map-selector-lng- Longitude input element.map-selector-radius- Radius input element.map-selector-polygon- Polygon input element
Validation
Laravel Validation Rules
Display Errors
Notes
- Requires a valid Google Maps API key in
MAP_API_KEYenvironment variable - The component extends the base Input component with
type="map-input" - Automatically extracts coordinates from Point objects when model binding
- Converts Polygon objects to WKT format for textarea display
- Falls back to
get_setting('default_lat')andget_setting('default_lng')for map center - Radius step is calculated dynamically based on
radiusPrecision - The Google Maps script is loaded once per page using
@pushonce - Supports both visible inputs and hidden inputs mode
- Compatible with Bootstrap 5 and Material Admin 26 frameworks