humaidem/filament-map-picker 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

humaidem/filament-map-picker

最新稳定版本:v0.1.5

Composer 安装命令:

composer require humaidem/filament-map-picker

包简介

无描述信息

README 文档

README

A Filament field to enable you select location in map and return geo coordinates.

Status Note

This package still in beta and not full tested. please use at your own risk.

Supported Maps

  1. Open Street Map (OSM)

More will be added to package once proven it's needed.

Installation

You can install the package via composer:

composer require humaidem/filament-map-picker

Basic usage

Resource file

<?php namespace App\Filament\Resources; use Filament\Resources\Resource; use Filament\Resources\Forms\Form; use Humaidem\FilamentMapPicker\Fields\OSMMap; ... class FilamentResource extends Resource { ... public static function form(Form $form) { return $form->schema([ OSMMap::make('location') ->label('Location') ->showMarker() ->draggable() ->extraControl([ 'zoomDelta' => 1, 'zoomSnap' => 0.25, 'wheelPxPerZoomLevel' => 60 ]) // tiles url (refer to https://www.spatialbias.com/2018/02/qgis-3.0-xyz-tile-layers/) ->tilesUrl('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}') ]); } ... }

Manipulating data

We will be using grimzy/laravel-mysql-spatial:^4.0 as example, you can use any other package as you please.

After State Hydrated

once data loaded from database you will need to convert it to correct format as livewire don't accept class base format.

... OSMMap::make('location') ->afterStateHydrated(function ($state, callable $set) { if ($state instanceof Point) { /** @var Point $state */ $set('location', ['lat' => $state->getLat(), 'lng' => $state->getLng()]); } }); ...

mutate Dehydrated State

convert array to Point class before storing data.

... OSMMap::make('location') ->mutateDehydratedStateUsing(function ($state) { if (!($state instanceof Point)) return new Point($state['lat'], $state['lng']); return $state; }); ...

After State Updated

Make sure to convert data into array after each time updated.

... OSMMap::make('location') ->afterStateUpdated(function ($state, callable $set) use ($name) { if ($state instanceof Point) { /** @var Point $state */ $set($name, ['lat' => $state->getLat(), 'lng' => $state->getLng()]); } }); ...

Options

Option Type Default Description
draggable(bool) bool false Allow user to move map around.
zoom(int) int 19 Default zoom when map loaded.
maxZoom(int) int 20 Max zoom allowed.
showMarker(bool) bool false Show Marker in the middle of the map
tilesUrl(string) string http://tile.openstreetmap.org/{z}/{x}/{y}.png Tiles service/provider url.
showZoomControl(bool) bool false Show or hide Zoom control of the map.
extraControl(array) array [] Add extra map controls (please refer to leaflet)
extraTileControl(array) array [] Add extra tileLayer controls (please refer to leaflet tileLayer())

License

MIT © Humaid Al Mansoori

Thanks for use

Hopefully, this package is useful to you.

统计信息

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

GitHub 信息

  • Stars: 59
  • Watchers: 2
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固