Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Commit 0bddb67

Browse files
feat: leaflet marker cluster (#65)
* added marker cluster, modified map to set a cluster * remove console log * meant to push this package file
1 parent 34efea6 commit 0bddb67

File tree

3 files changed

+47
-4
lines changed

3 files changed

+47
-4
lines changed

package-lock.json

Lines changed: 40 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"react": "^18.1.0",
1111
"react-dom": "^18.1.0",
1212
"react-leaflet": "^4.0.0",
13+
"react-leaflet-cluster": "^2.0.0",
1314
"react-scripts": "5.0.1",
1415
"serve": "^12.0.1",
1516
"socket.io-client": "^4.5.1",
@@ -48,4 +49,4 @@
4849
"overrides": {
4950
"autoprefixer": "10.4.5"
5051
}
51-
}
52+
}

src/components/map.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import MarkerClusterGroup from 'react-leaflet-cluster'
12
import { MapContainer, TileLayer, Marker, Popup } from "react-leaflet";
23
import * as L from "leaflet";
34
import "leaflet/dist/leaflet.css";
@@ -16,6 +17,9 @@ function Map({ events }) {
1617
attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
1718
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
1819
/>
20+
<MarkerClusterGroup
21+
chunkedLoading
22+
>
1923
{events.map(event => (
2024
<>
2125
<Marker
@@ -38,6 +42,7 @@ function Map({ events }) {
3842
</Marker>
3943
</>
4044
))}
45+
</MarkerClusterGroup>
4146
<Version />
4247
</MapContainer>
4348
);

0 commit comments

Comments
 (0)