Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Google Map Laravel Package

arcasolutions/google-map

Laravel package providing Google Maps integration for your app, with helpers to generate map views and include the required scripts. Useful for quickly embedding maps and configuring markers or map options within Laravel projects.

View on GitHub
Deep Wiki
Context7

Marker Cluster

Some applications are required to display a large number of locations or markers. Despite the v3 JavaScript API's significant improvement to performance, naively plotting thousands of markers on a map can quickly lead to to a degraded user experience. Too many markers on the map cause both visual overload and sluggish interaction with the map. To overcome this poor performance, the information displayed on the map needs to be simplified, we need a marker clustering solution.

The library provides one which can be easily used & extended :)

In fact, when you use a marker in your map, internally, a marker cluster is used. A map always manages markers with a marker cluster. Then, a marker cluster is a simple object which stores a type, markers & options:

use Ivory\GoogleMap\Map;
use Ivory\GoogleMap\Overlays\MarkerCluster;

$map = new Map();

$markerCluster = $map->getMarkerCluster();
$map->setMarkerCluster($markerCluster);

$type = $markerCluster->getType();
$markers = $markerCluster->getMarkers();
$options = $markerCluster->getOptions();

Default Marker Cluster

The default marker cluster is the marker cluster which does nothing... As a map has always a marker cluster, this implementation allows to fallback on the default google map behavior. To enable it:

use Ivory\GoogleMap\Overlays\MarkerCluster;

$markerCluster->setType(MarkerCluster::_DEFAULT);
$markerCluster->setType('default');

Javascript Marker Cluster

The javascript marker cluster provides a MarkerCluster integration. To enable it:

use Ivory\GoogleMap\Overlays\MarkerCluster;

$markerCluster->setType(MarkerCluster::MARKER_CLUSTER);
$markerCluster->setType('marker_cluster');

As this library can be configured, you can use options for that:

$markerCluster->setOption('gridSize', 50);
$markerCluster->setOption('maxZoom', 15);

Create your own marker cluster

As explain in the introduction, the marker cluster can be easily extended, meaning your can manage yourself the clustering. So, first step is create your own implementation:

namespace Acme\GoogleMap;

use Ivory\GoogleMap\Map;
use Ivory\GoogleMap\Helper\Overlays\MarkerCluster\AbstractMarkerClusterHelper;
use Ivory\GoogleMap\Overlays\MarkerCluster;

class MyFuckingMarkerClusterHelper extends AbstractMarkerClusterHelper
{
    /**
     * {[@inheritdoc](https://github.com/inheritdoc)}
     */
    public function render(MarkerCluster $markerCluster, Map $map)
    {
        // Your implementation
    }

    /**
     * {[@inheritdoc](https://github.com/inheritdoc)}
     */
    public function renderMarkers(MarkerCluster $markerCluster, Map $map)
    {
        // Your implementation
    }

    /**
     * {[@inheritdoc](https://github.com/inheritdoc)}
     */
    public function renderLibraries(MarkerCluster $markerCluster, Map $map)
    {
        // Your implementation
    }
}

After, you must register your marker cluster helper:

use Acme\GoogleMap\MyFuckingMarkerClusterHelper;
use Ivory\GoogleMap\Helper\MapHelper;

$mapHelper = new MapHelper();
$markerClusterHelper = new MyFuckingMarkerClusterHelper();

$mapHelper->getMarkerClusterHelper()->addHelper('my_helper', $markerClusterHelper);

Then, just use it:

$map = new Map();
$map->getMarkerCluster()->setType('my_helper');
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky