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 Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay