Creates and manages per-zoom-level clusters for large amounts of markers.
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.
Wrapper for the loading of Google Maps JavaScript API script in the...
Read moreCreates and manages per-zoom-level clusters for large amounts of markers...
Read more[](https://www.npmjs...
Read more[](https://www.npmjs...
Read more[](https://www.npmjs...
Read moreCore 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
A README file for the @googlemaps/markerclusterer code repository. View Code
The library creates and manages per-zoom-level clusters for large amounts of markers.
See the history section and migration section for how this library relates to @google/markerclusterer and @googlemaps/markerclustererplus.
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
.
This library uses the official TypeScript typings for Google Maps Platform, @types/google.maps.
npm i -D @types/google.maps
The reference documentation is generated from the TypeScript definitions.
import { MarkerClusterer } from "@googlemaps/markerclusterer";
// use default algorithm and renderer
const markerCluster = new MarkerClusterer({ map, markers });
View the package in action:
Algorithm Comparisons - This example demonstrates the different algorithms. Please note that spacing and many other options can be changed for each algorithm.
Renderer Usage - This example demonstrates different renderers similar to the image below.
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.
The API of @googlemaps/markerclusterer has changed in a number of ways from @googlemaps/markerclustererplus.
MarkerClusterer
class now accepts an algorithm
and renderer
parameter to allow for more flexibility. The interface looks like the following:{
algorithm?: Algorithm;
map?: google.maps.Map;
markers?: google.maps.Marker[];
renderer?: Renderer;
onClusterClick?: onClusterClickHandler;
}
MarkerClusterer
accepts a single options argument instead of positional parameters.GridAlgorithm
is still supported, but is not the default. The default is supercluster which uses k-d trees for improved performance.MarkerClusterer
class is still an instance of google.maps.OverlayView
, but uses google.maps.Marker
s instead of google.maps.Overlay
to render the clusters. This solves issues related to the usage of map panes and click handlers.