Laravel Mapcn
Toggle sidebar

Clusters

Docs / Clusters

Overview

The <x-map-cluster-layer> component efficiently handles large numbers of markers by grouping them into clusters. As you zoom in, clusters break apart into individual points. This is the recommended approach for datasets with hundreds or thousands of points.

For large datasets, always prefer <x-map-cluster-layer> over individual <x-map-marker> tags to maintain high frame rates.

Basic Usage

Pass GeoJSON Feature data to the cluster layer. Click on clusters to zoom in:

Custom Cluster Color

Change the cluster circle color to match your brand:

Data Format

The :data prop accepts an array of GeoJSON Feature objects. Each feature must have:

php
[
    'type' => 'Feature',
    'properties' => [
        'name' => 'Location Name',   // Any properties you want
    ],
    'geometry' => [
        'type' => 'Point',
        'coordinates' => [$lng, $lat],  // [longitude, latitude]
    ],
]
Remember that GeoJSON uses [longitude, latitude] order, not [latitude, longitude] — this is a common source of bugs.

Props

PropTypeDefaultDescription
:dataarrayrequiredGeoJSON Features or coordinate array
:cluster-max-zoomint14Max zoom level to cluster at
cluster-colorstring'#1A56DB'Color of the cluster circle
popup-propertystringnullFeature property to show in popup
:click-zoombooltrueZoom in on cluster click