Socket
Socket
Sign inDemoInstall

@googlemaps/markerclusterer

Package Overview
Dependencies
3
Maintainers
2
Versions
66
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @googlemaps/markerclusterer

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


Version published
Weekly downloads
687K
decreased by-0.71%
Maintainers
2
Install size
585 kB
Created
Weekly downloads
 

Readme

Source

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:

  • 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.

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.

  • The 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;
  }
  • The MarkerClusterer accepts a single options argument instead of positional parameters.
  • The traditional GridAlgorithm is still supported, but is not the default. The default is supercluster which uses k-d trees for improved performance.
  • Styling of clusters has been simplifed and moved to the renderer interface.
  • The MarkerClusterer class is still an instance of google.maps.OverlayView, but uses google.maps.Markers instead of google.maps.Overlay to render the clusters. This solves issues related to the usage of map panes and click handlers.
  • @googlemaps/markerclusterer supports Marker and Map a11y improvements.

Keywords

FAQs

Last updated on 29 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc