Download the PHP package genealabs/laravel-maps without Composer
On this page you can find all versions of the php package genealabs/laravel-maps. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download genealabs/laravel-maps
More information about genealabs/laravel-maps
Files in genealabs/laravel-maps
Package laravel-maps
Short Description Eay - peasy map integration for Laravel.
License MIT
Informations about the package laravel-maps
laravel-maps
Version Support
| Laravel | PHP |
|---|---|
| 11.x | 8.2, 8.3, 8.4, 8.5 |
| 12.x | 8.2, 8.3, 8.4, 8.5 |
| 13.x | 8.3, 8.4, 8.5 |
Prerequisites
- PHP >= 8.2
- Laravel >= 11.0
- A Google Maps API key
Installation
Add your Google Maps API key to .env:
Add the following entry to your config/services.php file:
Usage
The package provides a Map facade and an app('map') helper. Both
give you the same API — use whichever you prefer.
Every map follows the same pattern:
- Initialize the map with a config array.
- Add overlays (markers, polylines, polygons, etc.).
- Create the map to get the HTML and JavaScript output.
- Render the output in your Blade view.
Basic Map with Geolocation
This prompts the user for their location and centers the map on it:
Single Marker
Multiple Markers
Polyline
Polygon
Drawing Tools
Directions
When rendering, include a <div id="directionsDiv"></div> in your view
to display the turn-by-turn directions.
Street View
Marker Clustering
KML Layer
Circles
Rectangles
Ground Overlay
Rendering in Blade
Pass the map data to your view and render the JavaScript in your
<head> and the HTML in your <body>:
With a layout:
Controller Example
For more complex setups, use a dedicated controller:
API Reference
The Map facade (or app('map')) exposes the following methods:
| Method | Description |
|---|---|
initialize(array $config) |
Configure map center, zoom, type, and behavior |
add_marker(array $params) |
Add a marker with position, info window, icon, etc. |
add_polyline(array $params) |
Draw a polyline from an array of points |
add_polygon(array $params) |
Draw a filled polygon from an array of points |
add_circle(array $params) |
Draw a circle with center and radius |
add_rectangle(array $params) |
Draw a rectangle from bounds |
add_ground_overlay(array $params) |
Overlay an image on the map |
create_map() |
Generate the map and return ['js' => ..., 'html' => ...] |
get_lat_long_from_address(string $address) |
Geocode an address to lat/lng |
MultiPolygon from GeoJSON
To render a GeoJSON MultiPolygon, decode the JSON and call add_polygon() once per polygon in the collection:
Note: GeoJSON coordinates use
[longitude, latitude]order, but this library expects"latitude, longitude"strings. The example above swaps them accordingly.
Custom Overlay Popup
You can create a custom overlay popup that appears automatically (without requiring a click or hover) by using the onload configuration option together with the Google Maps JavaScript API custom popup example.
The approach has two parts:
- Define a custom
Popupoverlay class in a separate<script>tag. - Use the
onloadoption to instantiate the popup once the map finishes loading.
The onload JavaScript runs after the map initializes, so the map variable is available. The Popup class extends google.maps.OverlayView and positions custom HTML at a given lat/lng coordinate. The popup appears immediately without any user interaction.
You can also use the infowindow_content marker option for simpler popups that open on click:
To auto-open a standard info window without a click, use the onload option:
More Examples
BIOINSTALL has a great website showing how to do all the things with the class. No reason to reinvent the wheel, so here it is. The only thing to note is that $this->googlemaps is now either the facade Map:: or the app variable app('map').
License
This package is open-sourced software licensed under the MIT license.