Gathering detailed insights and metrics for react-leaflet-markercluster
Gathering detailed insights and metrics for react-leaflet-markercluster
Gathering detailed insights and metrics for react-leaflet-markercluster
Gathering detailed insights and metrics for react-leaflet-markercluster
@types/react-leaflet-markercluster
Stub TypeScript definitions entry for react-leaflet-markercluster, which provides its own types definitions
@changey/react-leaflet-markercluster
React wrapper of Leaflet.markercluster for react-laeflet
@christopherpickering/react-leaflet-markercluster
React wrapper of Leaflet.markercluster for react-laeflet
@greenatom/react-leaflet-markercluster
React wrapper of Leaflet.markercluster for react-laeflet
React wrapper of the official Leaflet.markercluster for react-leaflet
npm install react-leaflet-markercluster
Typescript
Module System
Node Version
NPM Version
91.3
Supply Chain
92.8
Quality
82.8
Maintenance
100
Vulnerability
99.3
License
JavaScript (52.52%)
MDX (45.38%)
SCSS (1.79%)
HTML (0.31%)
Total Downloads
7,364,873
Last Day
2,841
Last Week
29,431
Last Month
126,304
Last Year
1,242,758
MIT License
313 Stars
73 Commits
103 Forks
6 Watchers
4 Branches
15 Contributors
Updated on Mar 18, 2025
Minified
Minified + Gzipped
Latest Version
5.0.0-rc.0
Package Id
react-leaflet-markercluster@5.0.0-rc.0
Unpacked Size
41.51 kB
Size
10.18 kB
File Count
11
NPM Version
10.9.1
Node Version
20.14.0
Published on
Jan 03, 2025
Cumulative downloads
Total Downloads
Last Day
-42.6%
2,841
Compared to previous day
Last Week
-2.3%
29,431
Compared to previous week
Last Month
1.1%
126,304
Compared to previous month
Last Year
-9.8%
1,242,758
Compared to previous year
4
35
React wrapper of Leaflet.markercluster for react-leaflet
Examples with the Documentation: https://yuzhva.github.io/react-leaflet-markercluster/
CodeSandbox Getting Started
If you are faced with an issue with markers or polygons overlapping during map zooming, or they are
overlapping because they are close to each other - you probably need to group them.
That is what you can do with react-leaflet-markercluster.
Just grab your markers or ClusterableRegions inside <MarkerClusterGroup />
component, right after <TileLayer />
:
1import MarkerClusterGroup from "react-leaflet-markercluster"; 2 3<MarkerClusterGroup> 4 <Marker position={[49.8397, 24.0297]} /> 5 <Marker position={[52.2297, 21.0122]} /> 6 <Marker position={[51.5074, -0.0901]} /> 7</MarkerClusterGroup>;
Note: Before getting started, please see these useful guides:
1. Install package:
1yarn add react-leaflet-markercluster@next # yarn 2npm install react-leaflet-markercluster # npm
The react-leaflet-markercluster
requires leaflet.markercluster
as peerDependency
(Leaflet and react-leaflet also should be installed)
1yarn add leaflet.markercluster leaflet react-leaflet # yarn 2npm install leaflet.markercluster leaflet react-leaflet # npm
2. Import markercluster and leaflet styles:
1//sass 2@import '~leaflet/dist/leaflet.css'; 3@import '~react-leaflet-markercluster/styles'; 4 5//cjs 6require('~leaflet/dist/leaflet.css'); 7require('react-leaflet-markercluster/styles'); 8 9//esm 10import 'leaflet/dist/leaflet.css' 11import 'react-leaflet-markercluster/styles'
Or include CSS styles directly to the head of HTML file:
1<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" /> 2 3<link 4 rel="stylesheet" 5 href="https://unpkg.com/react-leaflet-markercluster/styles" 6/>
3. Write some simple react-leaflet
Map:
1import { MapContainer, TileLayer, Marker } from "react-leaflet"; 2 3<MapContainer 4 className="markercluster-map" 5 center={[51.0, 19.0]} 6 zoom={4} 7 maxZoom={18} 8> 9 <TileLayer 10 url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" 11 attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' 12 /> 13 14 <Marker position={[49.8397, 24.0297]} /> 15 <Marker position={[52.2297, 21.0122]} /> 16 <Marker position={[51.5074, -0.0901]} /> 17</MapContainer>;
NOTE: Remember to add map styles .markercluster-map { height: 90vh; }
.
4. Just put your markers or ClusterableRegions inside <MarkerClusterGroup />
component, right after <TileLayer />
:
1import MarkerClusterGroup from "react-leaflet-markercluster"; 2 3<MarkerClusterGroup> 4 <Marker position={[49.8397, 24.0297]} /> 5 <Marker position={[52.2297, 21.0122]} /> 6 <Marker position={[51.5074, -0.0901]} /> 7</MarkerClusterGroup>;
More examples with the Documentation
CodeSandbox Getting Started
Just pass whatever option you need from All Leaflet.markercluster Options to MarkerClusterGroup
as prop
.
For example:
1<MarkerClusterGroup showCoverageOnHover={false} />
or:
1const createClusterCustomIcon = function (cluster) { 2 return L.divIcon({ 3 html: `<span>${cluster.getChildCount()}</span>`, 4 className: 'marker-cluster-custom', 5 iconSize: L.point(40, 40, true), 6 }); 7} 8 9<MarkerClusterGroup iconCreateFunction={createClusterCustomIcon} />
P.S: Examples for v1 are available at CHANGELOG.md
You are able to add any listener, supported by Leaflet, with simple on
property prefix.
1. Clone the repo:
1git clone https://github.com/YUzhva/react-leaflet-markercluster.git
2. Install all dependencies:
1yarn install --no-lockfile # yarn 2npm install # npm
3. Start the server:
1yarn dev # yarn 2npm run dev # npm
4. After starting the server, storybook should automatically open the following address:
http://localhost:8080/
Thanks goes to these wonderful people:
Avatars rendered by contributors-img.
Special thanks to:
All sources are placed in the ./src
folder:
1. Fork the repo.
2. Edit react-leaflet-markercluster.js
plugin or style.scss
style files.
3. Commit your changes and open Pull Request.
:beer: Thank you for contribution :beer:
UMD builds are available on unpkg:
1<!-- unpkg, production code (minified) --> 2<script src="https://unpkg.com/react-leaflet-markercluster/dist/index.js"></script> 3<!-- unpkg, development code --> 4<script src="https://unpkg.com/react-leaflet-markercluster/src/react-leaflet-markercluster.js"></script> 5 6<!-- unpkg, production styles (minified) --> 7<link 8 rel="stylesheet" 9 type="text/css" 10 href="https://unpkg.com/react-leaflet-markercluster/styles" 11/> 12<!-- unpkg, development styles --> 13<link 14 rel="stylesheet" 15 type="text/css" 16 href="https://unpkg.com/react-leaflet-markercluster/src/styles.scss" 17/>
MIT License, see LICENSE file.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
2 existing vulnerabilities detected
Details
Reason
Found 3/15 approved changesets -- score normalized to 2
Reason
0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-04-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More