sadiq / filament-gmap-location-picker
A Filament field to enter and update latitude longitude based on map selection
1.1
2021-04-04 06:52 UTC
Requires
- php: ^7.4|^8.0
- filament/filament: ^1.6
README
A Filament field to enter and update latitude longitude based on map selection
Installation
You can install the package via composer:
composer require sadiq/filament-gmap-location-picker
Configuration
You have to set google maps javascript api key in your .env to use the package
GMAP_LOCATION_PICKER_KEY={YOUR_GOOGLE_MAP_KEY}
Basic usage
Use the field in your filament resources. If you need to bind the field to model property use resource field Sadiq\GMapLocationPicker\Resources\Fields\LocationPicker Or you can use Sadiq\GMapLocationPicker\Fields\LocationPicker and bind it to livewire property in your resource edit/create pages
<?php namespace App\Filament\Resources; use Filament\Resources\Resource; use Sadiq\GMapLocationPicker\Resources\Fields\LocationPicker; use Filament\Resources\Forms\Form; ... class FilamentResource extends Resource { ... public static function form(Form $form) { return $form->schema([ LocationPicker::make('point') ->defaultZoom(3) ->mapControls([ 'mapTypeControl' => false, 'scaleControl' => true, 'streetViewControl' => false, 'rotateControl' => false, 'fullscreenControl' => true, 'searchBoxControl' => false ]) ]); } ... }
Value format
The field output the value as array
[
'lat' => 0,
'lng' => 0
]