fathihfaiz / laravel-maps-suite
Laravel Blade components for Leaflet, Google Maps, and Mapbox integration.
v1.0.1
2025-04-10 11:02 UTC
Requires
- php: >=8.0
- illuminate/support: ^9.0|^10.0|^11.0
README
A Laravel Blade component library for embedding Leaflet, Google Maps, and Mapbox maps via Blade components, designed for simplicity and power.
๐ฆ Installation
composer require fathihfaiz/laravel-maps-suite
Publish Configuration and Views
php artisan vendor:publish --tag=maps-config php artisan vendor:publish --tag=maps-views
โ๏ธ Configuration
Edit your .env
file:
MAP_DRIVER=leaflet # or google / mapbox
GOOGLE_MAPS_API_KEY=your_google_key
MAPBOX_ACCESS_TOKEN=your_mapbox_token
You can edit default map behavior via config/mapsuite.php
.
๐ Supported Drivers
Driver | Props/Features | Notes |
---|---|---|
Leaflet | clustering , popupOptions , polylines , polygons |
Open-source, offline-friendly |
mapType , fitToBounds , centerToBoundsCenter |
API key required | |
Mapbox | style , accessToken |
Requires Mapbox token |
๐งฐ Blade Component Usage
๐งญ Generic auto-resolving map
<x-maps.generic :markers="[[ 'lat' => 51.5, 'lng' => -0.09, 'info' => 'London!' ]]" />
๐ Leaflet Example
<x-maps-leaflet :markers="[ ['lat'=>51.5, 'lng'=>-0.09, 'info'=>'A', 'icon'=>'/icon.png', 'open'=>true] ]" :zoom-level="12" :enable-clustering="true" :polylines="[[[51.5, -0.09], [51.51, -0.1]]]" :popup-options="['maxWidth' => 300]" :popup-content="'Standalone popup here'" :popup-lat-lng="[51.49, -0.08]" />
๐ฐ Google Maps Example
<x-maps-google :center-point="[37.7749, -122.4194]" :zoom-level="10" :map-type="'roadmap'" :markers="[ ['lat'=>37.77,'lng'=>-122.42, 'info'=>'San Francisco'] ]" :fit-to-bounds="true" :center-to-bounds-center="true" />
๐บ Mapbox Example
<x-maps-mapbox :center-point="[40.71, -74.0]" :zoom-level="13" :style="'mapbox/streets-v11'" :markers="[ ['lat'=>40.71, 'lng'=>-74.0, 'info'=>'Hello NYC'] ]" />
๐ Marker Schema
Each marker is an array with:
Prop | Type | Description |
---|---|---|
lat , lng |
float | Coordinates |
info |
string | Popup HTML/text |
open |
bool | Call .openPopup() |
label |
string | Tooltip/marker title |
icon |
string | URL to icon image |
iconSizeX |
int | Icon width |
iconSizeY |
int | Icon height |
draggable |
bool | Allow marker dragging |
๐งช Testing
To run a preview:
php artisan serve
Then test Blade calls from a view or Tinker.
Test cases should include:
- Basic render
- Popups
- Polyline and polygon display
- Dynamic clustering
๐ค Contributing
Pull requests welcome! To contribute:
- Fork this repo
- Create a new branch for your feature
- Follow current structure and naming
- Submit PR with description
๐ License
MIT ยฉ 2024 Fathih Faiz