Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update sizes of clusters #1073

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions sites/public/src/components/listings/MapClusterer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useCallback, useEffect, useMemo, useState, useContext } from "react"
import { InfoWindow, useMap } from "@vis.gl/react-google-maps"
import { MarkerClusterer } from "@googlemaps/markerclusterer"
import { MarkerClusterer, SuperClusterAlgorithm } from "@googlemaps/markerclusterer"
import { AuthContext } from "@bloom-housing/shared-helpers"
import { MapMarkerData } from "./ListingsMap"
import { MapMarker } from "./MapMarker"
Expand Down Expand Up @@ -164,8 +164,9 @@ export const MapClusterer = ({
const clusterMarker = document.createElement("div")
clusterMarker.className = styles["cluster-icon"]
clusterMarker.textContent = cluster.count.toString()
const DEFAULT_REM = 1.5
const calculatedSize = DEFAULT_REM + 0.02 * cluster.count
const DEFAULT_REM = 2
let calculatedSize = DEFAULT_REM + 0.04 * cluster.count
if (calculatedSize > 3.5) calculatedSize = 3.5
clusterMarker.style.width = `${calculatedSize}rem`
clusterMarker.style.height = `${calculatedSize}rem`
clusterMarker.setAttribute("data-testid", "map-cluster")
Expand All @@ -179,6 +180,7 @@ export const MapClusterer = ({
})
},
},
algorithm: new SuperClusterAlgorithm({ radius: 80 }),
onClusterClick: (_, cluster, map) => {
setInfoWindowIndex(null)
const zoomLevel = getBoundsZoomLevel(cluster.bounds)
Expand Down
Loading