arielmejiadev/leaflet-for-laravel

brings an easy integration to use leaflet javascript library using Laravel with blade views

Maintainers

Package info

github.com/ArielMejiaDev/leaflet-for-laravel

Homepage

pkg:composer/arielmejiadev/leaflet-for-laravel

Fund package maintenance!

arielmejiadev

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 5

1.1.0 2026-05-22 18:57 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A fluent, expressive PHP API for rendering Leaflet.js maps in Laravel — no JavaScript required.

Full Documentation

Quick Start

1. Install

composer require arielmejiadev/leaflet-for-laravel

2. Build a map in your controller

use arielmejiadev\LeafletForLaravel\LeafletMap;
use arielmejiadev\LeafletForLaravel\Marker;

class LandmarkController extends Controller
{
    public function index()
    {
        $map = LeafletMap::of('landmarks')
            ->center(40.6892, -74.0445)
            ->zoom(15)
            ->marker(40.6892, -74.0445, fn (Marker $pin) => $pin
                ->popup('<b>Statue of Liberty</b><br>New York, NY')
                ->icon('blue')
            );

        return view('landmarks.index', compact('map'));
    }
}

3. Render in Blade

<!DOCTYPE html>
<html>
<head>
    @leafletStyles
</head>
<body>
    @leafletMap($map)
</body>
</html>

That's it — two Blade directives and you have a live, interactive map.

Features

  • Pure PHP — write maps in PHP, zero JavaScript needed
  • Fluent API — chainable methods like ->center()->zoom()->marker()
  • Markers — popups, tooltips, draggable pins, colored icons, circles
  • Glyph Icons — Font Awesome & Material Design icons rendered on pins
  • Layer Control — multiple base map styles + toggleable overlay groups
  • GeoJSON — render points, lines, and feature collections
  • Blade Directives@leafletStyles + @leafletMap($map)
  • Livewire Ready — scaffold components with php artisan make:leaflet
  • Macros & Conditionals — extend with Map::macro(), branch with ->when()
  • Multiple Maps — independent instances on the same page

Installation

composer require arielmejiadev/leaflet-for-laravel

Optionally publish the config:

php artisan vendor:publish --tag="leaflet-for-laravel-config"

Documentation

Visit the full documentation site for guides on:

  • Maps — center, zoom, dimensions, tile layers, macros
  • Markers — popups, tooltips, icons, circles, bulk markers
  • Icons — colors, custom icons, Font Awesome & Material Design glyphs
  • Layer Control — base map switching, overlay groups
  • GeoJSON — points, lines, files, APIs
  • Advanced Example — full controller with everything combined
  • Artisan Command — generate PHP or Livewire map classes

Testing

composer test

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.