Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yemenpoint/filament-google-map-location-picker
filament-google-map-location-picker
https://github.com/yemenpoint/filament-google-map-location-picker
Last synced: 3 months ago
JSON representation
filament-google-map-location-picker
- Host: GitHub
- URL: https://github.com/yemenpoint/filament-google-map-location-picker
- Owner: yemenpoint
- License: mit
- Created: 2022-09-02T16:57:53.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-05T18:49:52.000Z (about 2 years ago)
- Last Synced: 2024-05-07T22:33:23.244Z (6 months ago)
- Language: Blade
- Size: 114 KB
- Stars: 30
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-filament - yemenpoint/filament-google-map-location-picker - A Google Maps location picker. (Fields)
README
# Google map Location Picker
forked from https://packagist.org/packages/sadiq/filament-gmap-location-picker## Installation
You can install the package via composer:
```php
composer require yemenpoint/filament-google-map-location-picker
```Optionally, you can publish the config using
```php
php artisan vendor:publish --tag="filament-google-map-location-picker-config"
```
### Config
#### filament-google-map-location-picker.php
```php"",
];```
## make migration location column to database
add location column to database```php
...
Schema::table('table_name', function (Blueprint $table) {
$table->json("location")->nullable();
});
...
``````php
use Yemenpoint\FilamentGoogleMapLocationPicker\Forms\Components\LocationPicker;...
public static function form(Form $form): Form
{
return $form->schema([
LocationPicker::make('location')
->default(json_encode(["lat" => 15.356893920277, "lng" => 44.173358011179]))//set default location
->defaultZoom(12)// set zoom
->setLocationCenter([
'lat' => 15.356893920277,
'lng' => 44.173358011179,
]) //set location center
->required()
->columnSpan(2),
]);
}
...```
####
### Model
#### add column name to fillable
```php
...protected $fillable = [
"location"
];
...
```#### if u have separate column for lat and lng add this Mutator
```php
...
function setLocationAttribute($value)
{
//replace lat_column_name and lng_column_name with your column names
$this->attributes['location'] = $value;
$_location = @json_decode($value,true);
$this->attributes['lat_column_name'] = data_get($_location,"lat");
$this->attributes['lng_column_name'] = data_get($_location,"lng");
}...
```## Credits
- [yemenpoint](https://github.com/yemenpoint)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.