maycolmunoz/moon-leaflet
最新稳定版本:4.0
Composer 安装命令:
composer require maycolmunoz/moon-leaflet
包简介
Leaflet field and component for MoonShine
关键字:
README 文档
README
MoonLeaflet adds interactive map support to MoonShine. It allows users to select coordinates directly from a map or display multiple locations visually with Leaflet.
- Map field with draggable marker
- Multiple available map layers
- Works in Form, Detail, and Index views
- Component mode with multiple markers
- Optional user geolocation support
- Customizable zoom, drag, and layer
🧱 Example Previews
| Field | Component |
|---|---|
![]() |
![]() |
Support MoonShine versions
| MoonShine | MoonLeaflet |
|---|---|
| 4.0+ | 4.0 |
🧩 Installation
composer require maycolmunoz/moon-leaflet
🚀 Usage
Field
use MaycolMunoz\MoonLeaflet\Fields\LeafletField; LeafletField::make('Location') // label ->initialPosition(latitude: 40.7580, longitude: -73.9855) //initial position ->columns('latitude', 'longitude') // columns in database ->draggable(true) // draggable market (optional) default is true
Component
use MaycolMunoz\MoonLeaflet\Components\LeafletMap; LeafletMap::make('Business Locations') // label ->initialPosition(latitude: 40.7580, longitude: -73.9855) //initial position ->items(fn () => Business::all() ->map(function (Business $business) { return [ 'name' => $business->name, 'latitude' => $business->latitude, 'longitude' => $business->longitude, ]; })->toArray()) // Each item must include name, latitude, and longitude
💡 The map will attempt to use the user's location if geolocation is enabled.
If unavailable, it defaults to coordinates(0, 0).
🌍 Options for field and component
->layer('OpenStreetMap') // map layer (default: OpenStreetMap) ->minZoom(5) // minimum zoom (default: 5) ->maxZoom(18) // maximum zoom (default: 18) ->zoom(14) // initial zoom (default: 14)
🌍 Available Map Layers
| Layer Name |
|---|
| OpenStreetMap |
| OpenTopoMap |
| CartoDB Dark Matter |
| CartoDB Positron |
| CartoDB Voyager |
| Esri WorldStreetMap |
| Esri Satellite |
统计信息
- 总下载量: 151
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-26

