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.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-maps

laravel-maps

GitHub (pre-)release Packagist GitHub license

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

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:

  1. Initialize the map with a config array.
  2. Add overlays (markers, polylines, polygons, etc.).
  3. Create the map to get the HTML and JavaScript output.
  4. 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:

  1. Define a custom Popup overlay class in a separate <script> tag.
  2. Use the onload option 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.


All versions of laravel-maps with dependencies

PHP Build Version
Package Version
Requires illuminate/support Version ^8.0|^9.0|^10.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package genealabs/laravel-maps contains the following files

Loading the files please wait ...