Laravel Mapbox, easily integrate Mapbox inside your Laravel app

koossaayy

Koussay

Posted on November 29, 2021

Laravel Mapbox, easily integrate Mapbox inside your Laravel app

I have just released Laravel Mapbox, a Laravel package that allows you to add Mapbox to your views easily, with highly flexibility.
It requires Laravel 8 and PHP 8.0 and up.

Before installing the package, create a Mapbox account to get your token.

Installation

To install the package, all you have to do is run this command

composer require koossaayy/laravel-mapbox 
Enter fullscreen mode Exit fullscreen mode

After the installation, add this key to the .env file

MAPBOX_TOKEN={your mapbox token here}
Enter fullscreen mode Exit fullscreen mode

And lastly publish the config file using this command :

php artisan vendor:publish --tag="mapbox-config"
Enter fullscreen mode Exit fullscreen mode

Also don't forget to add CSS and JS files of Mapbox

<link href='https://api.mapbox.com/mapbox-gl-js/v2.6.0/mapbox-gl.css' rel='stylesheet' />
<script src='https://api.mapbox.com/mapbox-gl-js/v2.6.0/mapbox-gl.js'></script>
Enter fullscreen mode Exit fullscreen mode

And that's It you're good to go

Usage

To show a map on a page, all you have to do is use :

<x-mapbox id="map" />
Enter fullscreen mode Exit fullscreen mode

The package comes with a lot with other options, like markers, popups, interactivity, and a lot.
You may check them here

If you like the package, give it a star, and everyone is more than welcome to contribute ♥

💖 💪 🙅 🚩
koossaayy
Koussay

Posted on November 29, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related