---
title: "<ScriptGoogleMapsMarkerClusterer> · Nuxt Scripts"
description: "Group nearby advanced markers and customize their cluster rendering."
canonical_url: "https://scripts.nuxt.com/scripts/google-maps/api/marker-clusterer"
meta:
  "og:description": "Group nearby advanced markers and customize their cluster rendering."
  "og:image": "https://scripts.nuxt.com/_og/s/o_52b75e659a389813.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "<ScriptGoogleMapsMarkerClusterer> · Nuxt Scripts"
  "twitter:image": "https://scripts.nuxt.com/_og/s/o_52b75e659a389813.png"
---

> Index of every page on this site: [llms.txt](https://scripts.nuxt.com/llms.txt)

**Api**

# **\<ScriptGoogleMapsMarkerClusterer>**

[Copy for LLMs](https://scripts.nuxt.com/scripts/google-maps/api/marker-clusterer.md)

Groups nearby markers into clusters at lower zoom levels. Place it inside a [`**<ScriptGoogleMaps>**`](https://scripts.nuxt.com/scripts/google-maps/api/script-google-maps) component. Google's [**marker clustering guide**](https://developers.google.com/maps/documentation/javascript/marker-clustering) explains the library and its accessibility rationale.

`**options**``Omit<MarkerClustererOptions, 'map'>`

Configuration options for the marker clusterer.

## Installation

Requires the `**@googlemaps/markerclusterer**` peer dependency:

```bash
pnpm add @googlemaps/markerclusterer
```

## Usage

Child markers register and unregister themselves automatically.

```vue
<script setup lang="ts">
const locations = ref([
  { id: 1, name: 'Sydney Opera House', position: { lat: -33.8568, lng: 151.2153 } },
  { id: 2, name: 'Bondi Beach', position: { lat: -33.8908, lng: 151.2743 } },
  { id: 3, name: 'Taronga Zoo', position: { lat: -33.8433, lng: 151.2411 } },
])
</script>

<template>
  <ScriptGoogleMaps
    api-key="your-api-key"
    :map-options="{
      center: { lat: -33.86, lng: 151.24 },
      zoom: 12,
    }"
  >
    <ScriptGoogleMapsMarkerClusterer>
      <ScriptGoogleMapsMarker
        v-for="location in locations"
        :key="location.id"
        :position="location.position"
      >
        <ScriptGoogleMapsInfoWindow>
          <div>{{ location.name }}</div>
        </ScriptGoogleMapsInfoWindow>
      </ScriptGoogleMapsMarker>
    </ScriptGoogleMapsMarkerClusterer>
  </ScriptGoogleMaps>
</template>
```

### Dynamic Markers

Markers added or removed reactively (e.g., via `**v-for**` with a changing list) automatically register with and unregister from the clusterer.

```vue
<script setup lang="ts">
const locations = ref([/* initial locations */])

function addLocation(position: google.maps.LatLngLiteral) {
  locations.value.push({ id: Date.now(), name: 'New', position })
}
</script>

<template>
  <ScriptGoogleMaps api-key="your-api-key">
    <ScriptGoogleMapsMarkerClusterer>
      <ScriptGoogleMapsMarker
        v-for="loc in locations"
        :key="loc.id"
        :position="loc.position"
      />
    </ScriptGoogleMapsMarkerClusterer>
  </ScriptGoogleMaps>
</template>
```

### Custom Algorithm

Pass `**algorithm**` through `**options**` to customize clustering behavior. See the [`**@googlemaps/markerclusterer**`** documentation**](https://googlemaps.github.io/js-markerclusterer/) for available algorithms.

The component reads `**options**` when it creates the clusterer and does not watch the prop afterward. Remount it to change the algorithm or other clusterer options at runtime.

```vue
<script setup lang="ts">
import { SuperClusterAlgorithm } from '@googlemaps/markerclusterer'

const clustererOptions = {
  algorithm: new SuperClusterAlgorithm({ radius: 200 }),
}
</script>

<template>
  <ScriptGoogleMaps api-key="your-api-key">
    <ScriptGoogleMapsMarkerClusterer :options="clustererOptions">
      <ScriptGoogleMapsMarker
        v-for="loc in locations"
        :key="loc.id"
        :position="loc.position"
      />
    </ScriptGoogleMapsMarkerClusterer>
  </ScriptGoogleMaps>
</template>
```

### Custom Cluster Renderer

Use the `**#renderer**` slot to customize how clusters look using Vue templates. The slot receives `**cluster**` (with `**count**`, `**position**`, `**markers**`), `**stats**`, and `**map**` (the Google Maps instance).

```vue
<template>
  <ScriptGoogleMaps api-key="your-api-key">
    <ScriptGoogleMapsMarkerClusterer>
      <template #renderer="{ cluster }">
        <div
          style="
            background: #4285f4;
            color: white;
            border-radius: 50%;
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
          "
        >
          {{ cluster.count }}
        </div>
      </template>

      <ScriptGoogleMapsMarker
        v-for="loc in locations"
        :key="loc.id"
        :position="loc.position"
      />
    </ScriptGoogleMapsMarkerClusterer>
  </ScriptGoogleMaps>
</template>
```

The `**#renderer**` slot overrides the `**renderer**` option. Each cluster gets its own `**AdvancedMarkerElement**` with the slot content as its visual.

The clusterer only renders its default slot after the clusterer instance is ready. This prevents child markers from mounting before the clusterer can receive them.

[Edit this page](https://github.com/nuxt/scripts/edit/main/docs/content/google-maps/2.api/4.marker-clusterer.md)

[Markdown For LLMs](https://scripts.nuxt.com/scripts/google-maps/api/marker-clusterer.md)

[**\<ScriptGoogleMapsInfoWindow>** Show an information window anchored to a marker or map position.](https://scripts.nuxt.com/scripts/google-maps/api/info-window) [**\<ScriptGoogleMapsCircle>** Draw a reactive circle overlay and handle its map events.](https://scripts.nuxt.com/scripts/google-maps/api/circle)

**On this page **

- [Installation](#installation)
- [Usage](#usage)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://scripts.nuxt.com/#website","@type":"WebSite","description":"Nuxt Scripts lets you load third-party scripts with better performance, privacy, security and DX. It includes many popular third-parties out of the box.","name":"Nuxt Scripts","url":"https://scripts.nuxt.com/","publisher":{"@id":"https://scripts.nuxt.com/#identity"}},{"@id":"https://scripts.nuxt.com/scripts/google-maps/api/marker-clusterer#webpage","@type":"WebPage","description":"Group nearby advanced markers and customize their cluster rendering.","name":"<ScriptGoogleMapsMarkerClusterer>","url":"https://scripts.nuxt.com/scripts/google-maps/api/marker-clusterer","breadcrumb":{"@id":"https://scripts.nuxt.com/scripts/google-maps/api/marker-clusterer#breadcrumb"},"isPartOf":{"@id":"https://scripts.nuxt.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://scripts.nuxt.com/scripts/google-maps/api/marker-clusterer"]}],"primaryImageOfPage":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/#identity","@type":"Organization","name":"Nuxt Scripts","url":"https://scripts.nuxt.com","logo":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/scripts/google-maps/api/marker-clusterer#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Nuxt Scripts","item":"https://scripts.nuxt.com/","position":1},{"@type":"ListItem","name":"Scripts","item":"https://scripts.nuxt.com/scripts","position":2},{"@type":"ListItem","name":"Google Maps","item":"https://scripts.nuxt.com/scripts/google-maps","position":3},{"@type":"ListItem","name":"API","item":"https://scripts.nuxt.com/scripts/google-maps/api","position":4},{"@type":"ListItem","name":"<ScriptGoogleMapsMarkerClusterer>","item":"https://scripts.nuxt.com/scripts/google-maps/api/marker-clusterer","position":5}]},{"@id":"https://scripts.nuxt.com/#logo","@type":"ImageObject","caption":"Nuxt Scripts","contentUrl":"https://scripts.nuxt.com/logo.svg","inLanguage":"en","url":"https://scripts.nuxt.com/logo.svg"}]}
```

## Sitemap

See the full [sitemap](https://scripts.nuxt.com/sitemap.md) for all pages.
