Download the PHP package imamhsn195/interactive-map without Composer
On this page you can find all versions of the php package imamhsn195/interactive-map. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download imamhsn195/interactive-map
More information about imamhsn195/interactive-map
Files in imamhsn195/interactive-map
Package interactive-map
Short Description A Laravel package for interactive maps using Leaflet.js. Provides an easy-to-use Blade component and helper functions to display interactive maps with multiple location markers.
License MIT
Homepage https://git.xhub.ae/imamhasan/interactive-map
Informations about the package interactive-map
Laravel Interactive Map
A Laravel package for interactive maps using Leaflet.js. This package provides an easy-to-use Blade component and helper functions to display interactive maps with multiple location markers.
Features
- πΊοΈ Interactive maps powered by Leaflet.js
- π Multiple location markers with popups
- π Click-to-zoom functionality
- π Auto-fit bounds to show all markers
- π Google Maps integration links
- π¨ Customizable styling
- βοΈ Configurable settings
Installation
Via Composer
For Local Development/Testing
If you want to test the package locally before publishing, see TESTING_LOCALLY.md for detailed instructions.
For publishing instructions, see PUBLISHING.md.
Quick setup:
-
Add path repository to your Laravel project's
composer.json:Note:
symlink: trueenables auto-sync - changes in the package are immediately reflected without runningcomposer update. See LOCAL_SETUP.md for details. - Install:
composer require imamhsn195/laravel-interactive-map:@dev - Publish assets:
php artisan vendor:publish --tag=interactive-map-assets
Step 1: Install Package
Step 2: Publish Assets (Optional)
If you want to customize the configuration, views, or assets:
Usage
Important: Layout Requirements
The map component uses Laravel's @push directive to add styles and scripts. Make sure your Blade layout file includes the corresponding @stack directives:
In your layout file (e.g., resources/views/layouts/app.blade.php):
Without these @stack directives, the map styles and JavaScript won't load, causing the map to not display properly.
Custom Stack Names:
If your layout uses different stack names (e.g., @stack('css') and @stack('js')), you can configure them in config/interactive-map.php:
Method 1: Using Blade Component (Recommended)
The easiest way to use the map is with the Blade component:
Method 2: Using Helper Function
Method 3: Using in Controller
Then in your Blade template:
Method 4: Using with Database Model
Location Data Format
Each location can have the following fields:
| Field | Required | Description | Alternative Names |
|---|---|---|---|
name |
Yes | Location name | title |
lat |
Yes | Latitude | latitude |
lng |
Yes | Longitude | longitude |
url |
No | Google Maps URL | map_url |
address |
No | Physical address | - |
description |
No | Additional description | - |
Configuration
After publishing the configuration file, you can customize the map settings in config/interactive-map.php:
Configuration Options
| Option | Default | Description |
|---|---|---|
tile_layer |
OpenStreetMap URL | Map tile provider |
attribution |
OSM attribution | Map attribution text |
zoom |
8 | Default zoom level |
padding |
[50, 50] | Bounds padding |
marker_click_zoom |
11 | Zoom level on marker click |
container.id |
'mapContainer' | Container element ID |
container.height |
'400px' | Default map height |
container.width |
'100%' | Default map width |
stacks.styles |
'styles' | Blade stack name for styles |
stacks.scripts |
'scripts' | Blade stack name for scripts |
Component Attributes
When using the Blade component, you can pass the following attributes:
locations(array, required): Array of location datacontainer-id(string, optional): Custom container IDheight(string, optional): Map height (e.g., '400px', '500px', '50vh'). Default: '400px'width(string, optional): Map width (e.g., '100%', '800px', '90vw'). Default: '100%'
Requirements
- PHP: ^8.1
- Laravel: ^9.0|^10.0|^11.0|^12.0
- Leaflet.js: 1.9.4 (loaded via CDN)
Browser Support
This package uses Leaflet.js, which supports all modern browsers:
- Chrome
- Firefox
- Safari
- Edge
- Opera
Customization
Custom Styling
After publishing assets, you can customize the CSS in public/vendor/interactive-map/css/interactive-map.css.
Custom Views
After publishing views, you can customize the Blade template in resources/views/vendor/interactive-map/map.blade.php.
Troubleshooting
Map not displaying
- Check your layout file - Ensure you have
@stack('styles')in<head>and@stack('scripts')before</body>in your Blade layout file. Without these, the map styles and JavaScript won't load. - Ensure Leaflet.js is loading correctly (check browser console)
- Verify the container ID is unique on the page
- Check that the container has a defined height
Markers not showing
- Verify location coordinates are valid (lat/lng)
- Check that locations array is not empty
- Ensure coordinates are within valid range (-90 to 90 for lat, -180 to 180 for lng)
Styles not applying
- Verify
@stack('styles')is in your layout - The component uses@push('styles')which requires@stack('styles')in your layout - Publish assets:
php artisan vendor:publish --tag=interactive-map-assets - Clear view cache:
php artisan view:clear - Check that CSS file is being loaded in browser DevTools
JavaScript not working
- Verify
@stack('scripts')is in your layout - The component uses@push('scripts')which requires@stack('scripts')in your layout - Check browser console for JavaScript errors
- Ensure Leaflet.js library is loading (check Network tab)
License
MIT License
Support
For issues, questions, or contributions, please visit the GitHub repository.
Changelog
See CHANGELOG.md for version history.
All versions of interactive-map with dependencies
illuminate/support Version ^9.0|^10.0|^11.0|^12.0
illuminate/view Version ^9.0|^10.0|^11.0|^12.0