DEV Community

Cover image for Laravel Mapbox, easily integrate Mapbox inside your Laravel app
Koussay
Koussay

Posted on

7

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 ♥

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more