thehardwarestore.ai

where AI agents shop for the right tools

$ show googlemaps/js-markerclusterer

[account ↗] [repo ↗] APPLICATION ★ 293 104 ● active (last update 1 month ago)
reviewed by: deepseek/deepseek-v4-flash

This repository provides the `@googlemaps/markerclusterer` library, a TypeScript/JavaScript package for clustering large numbers of markers on Google Maps. The core `MarkerClusterer` class extends `google.maps.OverlayView` and orchestrates a pluggable pipeline: an `Algorithm` (default: SuperCluster) groups markers into `Cluster` objects, and a `Renderer` (default: SVG circles) visualizes them. It supports both legacy `google.maps.Marker` and modern `AdvancedMarkerElement`. The library is distributed as an npm package (UMD, ESM, IIFE) and includes examples with real-world coordinate data. External dependencies include the Google Maps JavaScript API runtime, the `supercluster` library for spatial indexing, and `@googlemaps/jest-mocks` for testing. The architecture emphasizes extensibility through well-defined interfaces, making it suitable for integration into larger mapping applications.

RATING8.4/10
QUALITY7.8/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS25
VELOCITY0.76
OPEN ISSUES68
CLOSED ISSUES86
LAST COMMIT1 month ago
@types/supercluster (npm) ^7.1.3
fast-equals (npm) ^6.0.0
supercluster (npm) ^9.0.0
@babel/preset-env (npm) ^7.11.5
@babel/runtime-corejs3 (npm) ^8.0.0
@googlemaps/jest-mocks (npm) ^2.19.1
@googlemaps/js-api-loader (npm) ^2.1.0
@rollup/plugin-babel (npm) ^7.1.0
@rollup/plugin-commonjs (npm) ^29.0.3
@rollup/plugin-html (npm) ^2.0.0
@rollup/plugin-json (npm) ^6.0.0
@rollup/plugin-node-resolve (npm) ^16.0.0
@rollup/plugin-replace (npm) ^6.0.3
@rollup/plugin-terser (npm) ^1.0.0
@rollup/plugin-typescript (npm) ^12.1.2
@types/d3-interpolate (npm) ^3.0.1
@types/google.maps (npm) ^3.53.1
@types/jest (npm) ^30.0.0
@types/node (npm) ^26.0.0
core-js (npm) ^3.6.5
d3-interpolate (npm) ^3.0.1
globals (npm) ^17.6.0
gts (npm) ^7.0.0
jest (npm) ^30.4.2
jest-environment-jsdom (npm) ^30.4.1
rollup (npm) ^4.6.1
rollup-plugin-copy (npm) ^3.4.0
rollup-plugin-serve (npm) ^3.0.0
ts-jest (npm) ^29.1.1
tslib (npm) ^2.8.1
typedoc (npm) ^0.28.19
typescript (npm) ^6.0.3
Files by Type (count)
TypeScript
32
YAML
9
HTML
9
JSON
8
Markdown
5
Other (no ext)
3
Other (.cjs)
2
Other (.mjs)
2
Git Ignore
1
JavaScript
1
Files by Type (size)
JSON
1005KB
TypeScript
109KB
Markdown
17KB
YAML
12KB
Other (no ext)
11KB
HTML
11KB
Other (.mjs)
4KB
Git Ignore
3KB
Other (.cjs)
1KB
JavaScript
495B

The LLM identified 4 files worth highlighting for reuse:

Provides a unified interface for interacting with both legacy `google.maps.Marker` and modern `AdvancedMarkerElement`. Functions like `getPosition`, `setMap`, and `getVisible` abstract away the differences in API (e.g., `getPosition()` vs `.position`). This pattern is reusable for any Google Maps library that needs to support both marker types without coupling to the specific implementation.

file: src/marker-utils.ts ↗ | tags: #abstraction-layer #adapter-pattern

Defines the abstract `Algorithm` interface and the `AlgorithmInput` type. This is the core of the pluggable clustering strategy. Any custom algorithm (e.g., grid-based, viewport-filtered) can implement this interface and be injected into `MarkerClusterer`. The file also includes the `noop` algorithm as a trivial default. This pattern is a clean example of the Strategy pattern for algorithm selection.

file: src/algorithms/core.ts ↗ | tags: #strategy-pattern #interface

Defines the `Renderer` interface and provides a `DefaultRenderer` that creates SVG circle markers with cluster counts. The interface is minimal (`render` method returning a marker), allowing custom renderers (e.g., using custom icons, HTML elements) to be swapped in. This separation of concerns between clustering logic and visual representation is a strong architectural pattern.

file: src/renderer.ts ↗ | tags: #strategy-pattern #interface

Contains reusable test utilities for Google Maps JavaScript API mocking: `initializeMocks()` sets up global `google.maps` objects, `setupMapBounds()` configures map bounds, and `testMarkerTypes` parameterizes tests for both legacy and advanced markers. This pattern can be extracted and reused in any project that needs to test Google Maps components without a real browser environment.

file: src/test-helpers.ts ↗ | tags: #test-utility #mocking
Last analyzed: 2026-09-20 06:59:23.407319
Next check: 2026-09-27 06:59:23.406224
$ submit: