Download the PHP package sanderdewijs/lara-livewire-maps without Composer

On this page you can find all versions of the php package sanderdewijs/lara-livewire-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 lara-livewire-maps

Lara Livewire Maps

A lightweight Livewire v3 map component for Google Maps. It renders a map, places markers (optionally clustered), and lets users draw a selection (circle or polygon). When a selection is completed, events are dispatched with the markers inside the shape. If no markers are inside, useful selection metadata is returned.

Works out-of-the-box with Laravel 12 and Livewire 3.

Installation

Install via Composer:

Add the scripts directive to your layout (important)

This package ships a Blade include directive that loads the required JavaScript for the map and (optionally) the Google Maps API. Place the directive once per page, ideally immediately after the opening tag in your main layout.

Example layout:

Notes:

Requirements

The @LwMapsScripts directive loads the Google Maps JS API (drawing and geometry libraries) and the MarkerClusterer library. You can control this behavior via config (see below).

Configuration

You can configure package-wide defaults via config/livewire-maps.php. To publish the config file into your app, run:

You can also use the generic config tag:

After publishing, edit config/livewire-maps.php. Supported keys:

Asset loading options (Vite, Mix, CDN, file)

By default, asset_driver is file, which expects the package JS to be published to public/vendor. The @LwMapsScripts directive will then include it automatically.

Google Maps loading:

Quick Start

Render a map with a couple of markers:

Start drawing immediately (circle or polygon) by passing the drawType property:

Properties

All properties are optional unless noted. Use as Livewire props on the component tag.

Delayed initialization via custom event

Sometimes you want the map to initialize only after other backend work has completed. You can configure a custom event name globally or per component and dispatch it when you're ready.

When you're ready to initialize (e.g., after backend work completes), dispatch a Livewire/Alpine event with the same name as init_event.

Frontend (Alpine/Livewire in your Blade):

You can include overrides in the payload (all keys optional). These will be shallow-merged into the initial config:

Backend (Livewire PHP component):

Notes:

Marker shape

You can provide any of the following forms:

Notes:

Selection Drawing (Circle/Polygon)

The map supports starting draw mode in three ways:

1) Property: pass drawType on first render (see Quick Start). 2) Event via lw-map:update: include drawType: 'circle'|'polygon' to enable drawing immediately in the same update round-trip. 3) Event: ask the map to enter draw mode later (see Events below: lw-map:draw).

When the user completes the shape, the component computes which markers fall inside and dispatches a selection-complete event with results.

Events and Listeners (advanced/optional)

This package initially had support for custom browser events, but this will change to only Livewire event support for simplicity.

Map is ready

Example:

Update markers (and optionally toggle clustering)

Examples (from a Livewire PHP component):

Notes:

Runtime drawing via lw-map:update (single round-trip):

Enter/exit draw mode

Examples (backend PHP and frontend $dispatch):

Selection complete

Dispatched after the user completes a shape. Emitted on the Livewire client bus.

Example listener (Livewire v3 client bus):

Selection behavior and use cases

When a user finishes drawing a circle or polygon, the map emits a lw-map:selection-complete event. The intended follow-up action is inferred from whether the selection contains any of your markers.

Scenario 1: Area query (no markers captured)

Example payload (circle, no markers):

Example payload (polygon, no markers):

Scenario 2: Marker selection (one or more markers captured)

Example payload (markers selected):

Tips

Using with Livewire (recommended)

From a Livewire component, you can update markers or toggle clustering by dispatching the 'lw-map:update' event using named arguments (property: value):

Set or update the map center via Livewire

You can recenter the map by including a center in your Livewire dispatch for 'lw-map:update'. Pass the center as an associative array: ['lat' => ..., 'lng' => ...].

Examples:

Note: The update event replaces the marker list with what you send. If you only want to change the center, re-send your current markers as shown above.

Start/stop draw mode from Livewire

You can also control draw mode from your Livewire component using the same dispatch API:

Marker Clustering

When useClusters is true (at render time or via an update event), markers will be grouped using @googlemaps/markerclusterer loaded from a CDN. You can pass clusterOptions both at render and in update events.

Multiple Map Instances

Every map instance gets a unique DOM id (exposed in events as id).

Notes

Set both center and zoom via Livewire

You can update the map center and zoom level in a single update from your Livewire component:

Note: Always pass center as an associative array with 'lat' and 'lng' keys. The frontend will apply the zoom when provided.


All versions of lara-livewire-maps with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/contracts Version ^10.0 || ^11.0 || ^12.0
illuminate/support Version ^10.0 || ^11.0 || ^12.0
livewire/livewire Version ^3.6 || ^4.0
spatie/laravel-ray Version ^1.40
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 sanderdewijs/lara-livewire-maps contains the following files

Loading the files please wait ...