npm install @googlemaps/markerclusterer

Creates and manages per-zoom-level clusters for large amounts of markers.

About @googlemaps/markerclusterer

The @googlemaps/markerclusterer is an essential npm package designed to simplify the handling of large numbers of markers on Google Maps. This node module efficiently creates and manages clusters of markers at various zoom levels, enhancing the performance and user interface of map applications. By clustering markers, the package reduces the visual clutter on maps, making it easier for users to interact with the map and identify areas of interest. This is particularly beneficial for applications dealing with heavy data sets like real estate platforms, travel and tourism sites, and social media apps that incorporate geo-tagging.

To integrate this functionality into your project, you can easily install the package using the command npm install @googlemaps/markerclusterer. Once installed, it allows developers to implement marker clustering with a few lines of code, leveraging the robust Google Maps JavaScript API. The npm package ensures that as users zoom in and out, the clusters adjust dynamically, merging or separating markers based on the zoom level. This dynamic clustering not only improves load times and map performance but also enhances the overall user experience by maintaining a clean and navigable interface.

The @googlemaps/markerclusterer also supports customization options, allowing developers to define the appearance of clusters, including the size, icon, and style, to match the aesthetic of their application. This customization capability empowers developers to maintain a consistent look and feel across their applications, ensuring that the map features seamlessly integrate with the overall design. With its straightforward implementation and powerful clustering features, the @googlemaps/markerclusterer is a go-to solution for developers looking to enhance map functionalities in their applications.

More from googlemaps

googlemaps npm packages

Find the best node modules for your project.

Search npm

@googlemaps/js-api-loader

Wrapper for the loading of Google Maps JavaScript API script in the...

Read more
,

@googlemaps/markerclusterer

Creates and manages per-zoom-level clusters for large amounts of markers...

Read more
,

@googlemaps/google-maps-services-js

Node...

Read more
,

@googlemaps/url-signature

Sign a URL for Google Maps Platform requests...

Read more
,

@googlemaps/jest-mocks

[![npm](https://img.shields.io/npm/v/@googlemaps/jest-mocks)](https://www.npmjs...

Read more
,

@googlemaps/markerwithlabel

[![npm](https://img.shields.io/npm/v/@googlemaps/markerwithlabel)](https://www.npmjs...

Read more
,

@googlemaps/three

[![npm](https://img.shields.io/npm/v/@googlemaps/three)](https://www.npmjs...

Read more

Dependencies

Core dependencies of this npm package and its dev dependencies.

fast-deep-equal, supercluster, @babel/preset-env, @babel/runtime-corejs3, @googlemaps/jest-mocks, @googlemaps/js-api-loader, @rollup/plugin-babel, @rollup/plugin-commonjs, @rollup/plugin-html, @rollup/plugin-json, @rollup/plugin-node-resolve, @rollup/plugin-typescript, @types/d3-interpolate, @types/google.maps, @types/jest, @types/supercluster, @typescript-eslint/eslint-plugin, @typescript-eslint/parser, core-js, d3-interpolate, eslint, eslint-config-prettier, eslint-plugin-jest, eslint-plugin-prettier, jest, prettier, rollup, rollup-plugin-copy, rollup-plugin-serve, rollup-plugin-terser, selenium-webdriver, ts-jest, typedoc, typescript

Documentation

A README file for the @googlemaps/markerclusterer code repository. View Code

Google Maps JavaScript MarkerClusterer

npm Build Release codecov GitHub contributors semantic-release

Description

The library creates and manages per-zoom-level clusters for large amounts of markers.

Try the demo

screenshot

See the history section and migration section for how this library relates to @google/markerclusterer and @googlemaps/markerclustererplus.

Install

Available via npm as the package @googlemaps/markerclusterer.

npm i @googlemaps/markerclusterer

Alternativly you may add the umd package directly to the html document using the unpkg link.

<script src="https://unpkg.com/@googlemaps/markerclusterer/dist/index.min.js"></script>

When adding via unpkg, the MarkerClusterer can be accessed at markerClusterer.MarkerClusterer.

TypeScript

This library uses the official TypeScript typings for Google Maps Platform, @types/google.maps.

npm i -D @types/google.maps

Documentation

The reference documentation is generated from the TypeScript definitions.

Examples

import { MarkerClusterer } from "@googlemaps/markerclusterer";

// use default algorithm and renderer
const markerCluster = new MarkerClusterer({ map, markers });

View the package in action:

Screen Shot 2021-09-28 at 1 41 06 PM

History

This library has a heritage in @google/markerclusterer and @googlemaps/markerclustererplus, originally made available on code.google.com and then transferred to GitHub at https://github.com/googlemaps/v3-utility-library. The following is an approximate timeline.

Migration

The API of @googlemaps/markerclusterer has changed in a number of ways from @googlemaps/markerclustererplus.

{
    algorithm?: Algorithm;
    map?: google.maps.Map;
    markers?: google.maps.Marker[];
    renderer?: Renderer;
    onClusterClick?: onClusterClickHandler;
  }