hanyfreestyle/filament-locationpickr-field
Composer 安装命令:
composer require hanyfreestyle/filament-locationpickr-field
包简介
Location picker field for Filament Php using Google Maps
关键字:
README 文档
README
This package provides just a simplified location picker field within Filament using Google Maps based on the excellent work of Hugh Messenger.
Installation
You can install the package into a Laravel app that uses Filament via composer::
composer require arbermustafa/filament-locationpickr-field:"^2.0.0"
Filament V2 - if you are using Filament v2.x, you can use 1.x branch.
You can publish the config file with:
php artisan vendor:publish --tag=filament-locationpickr-field-config
The config file contains default global customization options for map rendering, like: api key, default location, etc.
Optionally, you can publish the view using:
php artisan vendor:publish --tag=filament-locationpickr-field-views
Setting your Google Maps API Key
All use of the Google Maps API requires an API key. If you don't have one, refer to Google's documentation.
Once you have a key, either add it to your .env file as:
GMAP_API=your_map_api_key_here
... or publish and edit the filament-locationpickr-field.php config file.
Preparing the models
Add a location column to any model migration schema used for map data
... Schema::table('table_name', function (Blueprint $table) { $table->json('location')->nullable(); }); ...
and add the column to the model fillable array
... protected $fillable = [ ... 'location', ];
If you have separate columns for lat and lng you can use a computed property on any model being used for map data and use a mutator which converts between separate lat and lng fields on your table, and a Google Point style array of 'lat' and 'lng' keys.
... protected $appends = [ ... 'location', ]; ... public function location(): Attribute { return Attribute::make( get: fn ($value, $attributes) => json_encode([ 'lat' => (float) $attributes['lat'], 'lng' => (float) $attributes['lng'], ]), set: fn ($value) => [ 'lat' => $value['lat'], 'lng' => $value['lng'], ], ); } ...
Usage
Form field
The form field can be used with no options, by simply adding this to your Filament Form schema:
use ArberMustafa\FilamentLocationPickrField\Forms\Components\LocationPickr; ... ->schema([ ... LocationPickr::make('location'), .... ]); ...
The name used in the make() function must be the one you set up as your model's column/computed location property.
Full options
The full set of options is as follows. All option methods support closures, as well as direct values.
use ArberMustafa\FilamentLocationPickrField\Forms\Components\LocationPickr; ... ->schema([ ... LocationPickr::make('location') ->mapControls([ 'mapTypeControl' => true, 'scaleControl' => true, 'streetViewControl' => true, 'rotateControl' => true, 'fullscreenControl' => true, 'zoomControl' => false, ]) ->defaultZoom(5) ->draggable() ->clickable() ->height('40vh') ->defaultLocation([41.32836109345274, 19.818383186960773]) ->myLocationButtonLabel('My location'), .... ]); ...
Infolist entry
The infolist entry can be used with no options, by simply adding this to your Filament Infolist schema:
use ArberMustafa\FilamentLocationPickrField\Infolists\Components\LocationPickr; ... ->schema([ ... LocationPickr::make('location'), .... ]); ...
The name used in the make() function must be the one you set up as your model's column/computed location property. The components accepts options like defaultZoom, defaultLocation and height.
Example usage in simple resource
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
If you want to contribute to this package, you may want to test it in a real Filament project:
- Fork this repository to your Github account.
- Create a Filament app locally.
- Clone your fork in your Filament app root directoy.
- In the
/filament-locationpickr-fielddirectory, create a branch for your fix/improvement, e.g.fix/pickr-field.
Install the package in your app's composer.json:
"require": { "arbermustafa/filament-locationpickr-field": "dev-fix/pickr-field as dev-main", }, "repositories": [ { "type": "path", "url": "./filament-locationpickr-field" } ]
Now run composer update.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
hanyfreestyle/filament-locationpickr-field 适用场景与选型建议
hanyfreestyle/filament-locationpickr-field 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 70 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 04 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「form」 「google-maps」 「maps」 「laravel」 「field」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 hanyfreestyle/filament-locationpickr-field 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hanyfreestyle/filament-locationpickr-field 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 hanyfreestyle/filament-locationpickr-field 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Maps in minutes. Powered by the Google Maps API.
Diese Contao 4 Erweiterung stellt Google reCAPTCHA V2 in Form eines neuen Formularfeldes im Formulargenerator bereit. This extension provides Google reCAPTCHA V2 in the form of a new form field in the form generator of Contao Open Source CMS.
Harness the power of the Google Autocomplete API inside Craft. Adds an autocomplete search box to Craft entries.
Laravel package that helps to use GoogleMaps
A Laravel Filament Forms slug field.
A jQuery augmented PHP library for creating and validating HTML forms
统计信息
- 总下载量: 70
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-13
