Merged in feat/SW-1750-map-connection (pull request #1439)

Feat(SW-1750): Destination page map connection 

Approved-by: Erik Tiekstra
This commit is contained in:
Matilda Landström
2025-03-03 07:56:40 +00:00
parent 21255f8557
commit 3f01266a75
8 changed files with 114 additions and 53 deletions

View File

@@ -1,5 +1,5 @@
import { useEffect, useMemo, useReducer } from "react"
import Supercluster, {type ClusterProperties } from "supercluster"
import Supercluster, { type ClusterProperties } from "supercluster"
import { useMapViewport } from "./use-map-viewport"
@@ -36,7 +36,16 @@ export function useSupercluster<T extends GeoJsonProperties>(
return clusterer.getClusters(bbox, zoom)
}, [version, clusterer, bbox, zoom])
// retrieve the hotel ids included in the cluster
const containedHotels = clusters.map((cluster) => {
if (cluster.properties?.cluster && typeof cluster.id === "number") {
return clusterer.getLeaves(cluster.id).map((hotel) => Number(hotel.id))
}
return []
})
return {
clusters,
containedHotels,
}
}