lbcdev/filament-maps-widgets
Composer 安装命令:
composer require lbcdev/filament-maps-widgets
包简介
Interactive map widgets for Filament panels
README 文档
README
Interactive map widgets for Filament panels, built on top of livewire-maps-core and map-geometries.
Installation
You can install the package via composer:
composer require lbcdev/filament-maps-widgets
Optionally, you can publish the config file with:
php artisan vendor:publish --tag="filament-maps-widgets-config"
Quick Start
Create a map widget by extending MapWidget:
namespace App\Filament\Widgets; use LBCDev\FilamentMapsWidgets\Widgets\MapWidget; use LBCDev\MapGeometries\Marker; use LBCDev\MapGeometries\MarkerCollection; class LocationsMap extends MapWidget { protected function getMarkers(): MarkerCollection { $markers = new MarkerCollection(); $markers->add( Marker::make('home') ->lat(40.7128) ->lng(-74.0060) ->popup('New York City') ); return $markers; } protected function getMapCenter(): array { return ['lat' => 40.7128, 'lng' => -74.0060]; } }
Features
- 🗺️ Easy Integration: Built specifically for Filament panels
- 🎨 Customizable: Configure map center, zoom, options, and more
- 🎯 Actions System: Add custom actions/controls to your maps
- 🧩 Modular: Built on top of separate core and geometries packages
- ✅ Well Tested: Comprehensive test coverage
- 📚 Documented: Full API documentation
Basic Usage
Simple Map Widget
use LBCDev\FilamentMapsWidgets\Widgets\MapWidget; use LBCDev\MapGeometries\Marker; class MyMap extends MapWidget { protected function getMarkers(): array { return [ Marker::make('marker-1') ->lat(51.505) ->lng(-0.09) ->popup('London'), ]; } }
Custom Map Configuration
class MyMap extends MapWidget { protected function getMapCenter(): array { return ['lat' => 51.505, 'lng' => -0.09]; } protected function getMapZoom(): int { return 13; } protected function getMapOptions(): array { return [ 'scrollWheelZoom' => true, 'dragging' => true, 'minZoom' => 10, 'maxZoom' => 18, ]; } }
Dynamic Markers from Database
use App\Models\Location; class LocationsMap extends MapWidget { protected function getMarkers(): MarkerCollection { $markers = new MarkerCollection(); Location::all()->each(function ($location) use ($markers) { $markers->add( Marker::make($location->id) ->lat($location->latitude) ->lng($location->longitude) ->color($location->is_active ? 'green' : 'red') ->popup("<b>{$location->name}</b><br>{$location->address}") ); }); return $markers; } }
Adding Actions
use LBCDev\FilamentMapsWidgets\Actions\ZoomAction; class MyMap extends MapWidget { protected function getActions(): array { return [ ZoomAction::make() ->position('topright'), ]; } }
Configuration
The package comes with sensible defaults, but you can customize everything via the config file:
return [ 'default_center' => [ 'lat' => 0, 'lng' => 0, ], 'default_zoom' => 10, 'default_height' => '500px', 'map_options' => [ 'scrollWheelZoom' => true, 'dragging' => true, // ... more options ], ];
Advanced Usage
Reactive Widgets with Filters
class FilteredMap extends MapWidget { public array $filters = []; protected $listeners = [ 'filtersUpdated' => 'handleFiltersUpdated', ]; public function mount(array $filters = []): void { $this->filters = $filters; parent::mount(); } protected function getMarkers(): MarkerCollection { // Apply filters to your query $query = Location::query(); if ($this->filters['category'] ?? null) { $query->where('category_id', $this->filters['category']); } // Build markers from filtered results // ... } public function handleFiltersUpdated(array $filters): void { $this->filters = $filters; $this->refresh(); } }
Custom Height and Styling
class MyMap extends MapWidget { public string $height = '700px'; protected bool $hasBorder = true; }
Testing
composer test
Or with coverage:
composer test-coverage
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
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.
Related Packages
This package is part of the LBCDev Maps Suite:
- livewire-maps-core - Core Livewire map component
- map-geometries - Map geometry classes (Marker, Polyline, etc.)
- filament-maps-fields - Map form fields for Filament
- lbcdev-filament-maps-suite - Meta-package for all components
lbcdev/filament-maps-widgets 适用场景与选型建议
lbcdev/filament-maps-widgets 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 02 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「maps」 「laravel」 「widgets」 「leaflet」 「livewire」 「filament」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 lbcdev/filament-maps-widgets 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lbcdev/filament-maps-widgets 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 lbcdev/filament-maps-widgets 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
An alternative to the SilverStripe Widgets module.
A Laravel Nova Google Maps Field.
Google Maps PHP SDK.
Widgets collection for Yii2
A Google Maps library for WordPress.
An easy way to integrate Google Maps with Laravel.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-16