Merged in feat/SW-2241-country-map (pull request #2808)
Feat/SW-2241 country map Approved-by: Erik Tiekstra Approved-by: Chuma Mcphoy (We Ahead)
This commit is contained in:
@@ -5,6 +5,8 @@ import { useMapViewport } from "./use-map-viewport"
|
||||
|
||||
import type { FeatureCollection, GeoJsonProperties, Point } from "geojson"
|
||||
|
||||
import type { CityMarkerProperties } from "@/types/components/maps/destinationMarkers"
|
||||
|
||||
export function useSupercluster<T extends GeoJsonProperties>(
|
||||
geojson: FeatureCollection<Point, T>,
|
||||
superclusterOptions: Supercluster.Options<T, ClusterProperties>
|
||||
@@ -45,16 +47,29 @@ export function useSupercluster<T extends GeoJsonProperties>(
|
||||
}
|
||||
|
||||
// retrieve the hotel ids included in the cluster
|
||||
const containedHotels = clusters.map((cluster) => {
|
||||
const containedHotelIds = clusters.map((cluster) => {
|
||||
if (cluster.properties?.cluster && typeof cluster.id === "number") {
|
||||
return clusterer.getLeaves(cluster.id).map((hotel) => Number(hotel.id))
|
||||
return clusterer
|
||||
.getLeaves(cluster.id)
|
||||
.map((location) => String(location.id))
|
||||
}
|
||||
return []
|
||||
})
|
||||
|
||||
// retrieve the city ids included in the cluster
|
||||
const containedCityIds = clusters.map((cluster) => {
|
||||
if (cluster.properties?.cluster && typeof cluster.id === "number") {
|
||||
return clusterer
|
||||
.getLeaves(cluster.id)
|
||||
.map((city) => city.properties as CityMarkerProperties)
|
||||
}
|
||||
return []
|
||||
})
|
||||
|
||||
return {
|
||||
clusters,
|
||||
containedHotels,
|
||||
containedHotelIds,
|
||||
containedCityIds,
|
||||
getClusterZoom,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user