Install the package using Composer:
composer require kwasii/livewire-mapcn
Publish the configuration file and assets to customize default behaviour:
php artisan vendor:publish --tag="livewire-mapcn-config" php artisan vendor:publish --tag="livewire-mapcn-assets"
Include the styles and scripts in your root layout file (e.g., app.blade.php):
<head> <!-- ... --> @livewireMapStyles </head> <body> <!-- ... --> @livewireMapScripts </body>
Customize the package behaviour via config/livewire-mapcn.php:
| Key | Default | Description |
|---|---|---|
| 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 |
After installation, verify everything works by adding a simple map to any Blade view: