承接 lbcdev/filament-maps-widgets 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lbcdev/filament-maps-widgets

最新稳定版本:v2.0.0

Composer 安装命令:

composer require lbcdev/filament-maps-widgets

包简介

Interactive map widgets for Filament panels

README 文档

README

Latest Version on Packagist Total Downloads

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:

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固