Laravel Mapcn
Toggle sidebar

Installation

Docs / Installation

1. Install via Composer

Install the package using Composer:

terminal
composer require kwasii/livewire-mapcn

2. Publish Configuration & Assets

Publish the configuration file and assets to customize default behaviour:

terminal
php artisan vendor:publish --tag="livewire-mapcn-config"
php artisan vendor:publish --tag="livewire-mapcn-assets"

3. Setup Layout

Include the styles and scripts in your root layout file (e.g., app.blade.php):

blade
<head>
    <!-- ... -->
    @livewireMapStyles
</head>
<body>
    <!-- ... -->
    @livewireMapScripts
</body>
Ensure you have Alpine.js and Tailwind CSS installed in your project, as they are required dependencies.

Configuration

Customize the package behaviour via config/livewire-mapcn.php:

KeyDefaultDescription
default_provider 'carto-positron' Default tile provider for all maps
dark_provider 'carto-dark-matter' Provider used for dark mode
default_height 'full' Default CSS height if not specified in prop
default_zoom 7 Default initial zoom level
default_center [0, 0] Default initial coordinates [lng, lat]
osrm_url router.project-osrm.org Base URL for fetching road directions
inject_assets 'route' 'route' (auto-load) or 'published' (manual)
load_from_cdn true Load MapLibre JS/CSS from CDN or locally

Verify Installation

After installation, verify everything works by adding a simple map to any Blade view: