也门点 / filament-google-map-location-picker
此包的最新版本(v2.2)没有可用的许可证信息。
filament 的谷歌地图位置选择器
v2.2
2022-11-05 18:49 UTC
Requires
- filament/filament: 2.*
README
从 https://packagist.org.cn/packages/sadiq/filament-gmap-location-picker 分支
安装
您可以通过 composer 安装此包
composer require yemenpoint/filament-google-map-location-picker
可选地,您可以使用以下命令发布配置
php artisan vendor:publish --tag="filament-google-map-location-picker-config"
配置
filament-google-map-location-picker.php
<?php return [ 'google_map_key' => "", ];
将位置列迁移到数据库
向数据库添加位置列
... Schema::table('table_name', function (Blueprint $table) { $table->json("location")->nullable(); }); ...
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), ]); } ...

模型
将列名添加到 fillable
... protected $fillable = [ "location" ]; ...
如果您有单独的经纬度列,请添加此 Mutator
... 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"); } ...
致谢
许可证
MIT 许可证(MIT)。请参阅 许可证文件 获取更多信息。